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?
prime = [ 2,3,5,7,11,13,17,19]
result = 1
for i in prime:
result *= i
for i in range(2,21):
if result % i==0:continue
tmp = i
for j in prime:
if tmp % j == 0:
tmp = tmp / j
result *= tmp
print result
def gcd(a,b):
if b == 0:return a
else:return gcd(b,a%b)
def lcm(a,b):
return ( a/gcd(a,b) )*b
r = 2
for i in range(3,21):
r = lcm(r,i)
print r