Multiples of 3 and 5


Fork me on GitHub
2014-09-11

Problem 001: Multiples of 3 and 5

Description:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.


Solution:
vvv:           <           <
1> 1+:::3/3*-!#^_>::5/5*-!#^_v
1$v          ># v#      ># v#<
1 >:5558***-!|v$<>+\:1-!|v$<
>^           <>$$^\     <>.@
Start
??
Pause
Reset
Output:
Stack:   (0)

Explanation:

The solution here is pretty straight-forward, going through all numbers from 1-1000 and adding all multiples of 3 and 5 together.


Interpreter steps: 47 624
Execution time (BefunExec): 62ms (0.77 MHz)
Program size: 30 x 5 (fully conform befunge-93)
Solution: 233168
Solved at: 2014-09-11



made with vanilla PHP and MySQL, no frameworks, no bootstrap, no unnecessary* javascript