求1,20的最小公倍数,十分简单,
def gcd(x, y):
if x < y:
x, y = y, x
while y:
x, y = y, x % y
return x
def lcm(x, y):
return x * y / gcd(x, y)
ans = 1
for x in range(2,21):
ans = lcm(ans, x)
print(ans)
求1,20的最小公倍数,十分简单,
def gcd(x, y):
if x < y:
x, y = y, x
while y:
x, y = y, x % y
return x
def lcm(x, y):
return x * y / gcd(x, y)
ans = 1
for x in range(2,21):
ans = lcm(ans, x)
print(ans)