1
0
www.mikescher.com/www/statics/euler/Euler_Problem-005_explanation.md

11 lines
562 B
Markdown
Raw Permalink Normal View History

2017-11-08 17:39:50 +01:00
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