Problem 5: Smallest Multiple
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?
def check(n, limit):
for i in range(2, limit+1):
if n % i:
return False
return True
def smallest_mult(limit):
i = limit
while True:
if check(i, limit):
num = i
break
i += limit
return num
print(smallest_mult(20))
Click to reveal output
232792560