So I tried writing an algorithm that would compute the smallest multiple of the numbers from 1-20. Here's my code:
multiples = range(2,11)
check = False
start = 1
while check is False:
n = [start%i for i in multiples]
if sum(n) == 0:
check = True
print(start)
else:
start = start+1
As it is, it works at range(2,11)
and gives the right answer (2520). However, when I try to scale the code to range(2,21)
, it doesn't seem to generate an answer (it loops infinitely). Can anyone tell me what's wrong with it?