Problem 5

Problem Statement

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Approach

Python implementation

```
````import math`

`res = 0`

`def divisors(x):`

` for i in range(1,21):`

` if x % i != 0:`

` return False`

` return True`

`def find_min(maxint):`

` res = 2`

` for i in range(3,maxint+1):`

` prime = True`

` for j in range(2, i):`

` if i % j == 0:`

` prime = False`

` break`

` if prime == True:`

` res = res * i`

` # check if current min satisfies divisibility for all ints`

` for k in range(1, maxint+1):`

` if res % k != 0: `

` # now find smallest prime factor in i and multiply`

` # total value by that`

` for g in range(2, k):`

` if k % g == 0:`

` res = res * g`

` break`

` return res`

` `

`res = find_min(20)`

`print("Answer is " + str(res))`

You can also download the source code for this problem here and compile it on your local machine.

Further Analysis