Project Euler 5 Smallest multiple

Project Euler 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?
'''
from math import *

def getm(i):
    j=  2
    while j<=20:
        if i%j<>0:
            return 0
        j+=1
    return 1
            
i=1 
while i:
    if getm(i)==1:
        print i
        break
    i+=1
    

你可能感兴趣的:(pytho)