-
Notifications
You must be signed in to change notification settings - Fork 1
/
Euler_Problem-005.b93
27 lines (20 loc) · 1.1 KB
/
Euler_Problem-005.b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
45*00p110p120p >10g20g*10p00g20g1+:20p`#v_10g.@
^_v#`g00p03+1:g03 <p031< v <
>10g30g% |1 <^ p01/g03g01<
>10g30g/40p150p > 20g50g1+:50p` #v_^
^ < |!%g05g04 <
^<
[00] 20 (const)
[10] value
[20] current-mult (1 .. 20)
[30] divisor (for reducing)
[40] value/divisor
[50] test-mult (1 .. current-mult)
---------------------------------------
We start with a value of `1`.
Then we multiply one after another the numbers from `1` to `20` to our value (We call these `multiplicand` in the loop).
After each multiplications we search go through the numbers from `2` to `value` and search for a number `divisor` where
- `value % divisor == 0`
- `(value / divisor) % {0, multiplicand} == 0`
Then (after we found such a number) we can reduce the value with it (`value /= divisor`).
The reduction steps guarantees us that we find the **smallest** number and it prevents our *Int64* numbers from overflowing