求1,20的最小公倍数,十分简单,
def gcd(x, y): if x < y: x, y = y, x while y: x, y = y, x % y return xdef lcm(x, y): return x * y / gcd(x, y)ans = 1for x in range(2,21): ans = lcm(ans, x)print(ans)
本文共 266 字,大约阅读时间需要 1 分钟。
求1,20的最小公倍数,十分简单,
def gcd(x, y): if x < y: x, y = y, x while y: x, y = y, x % y return xdef lcm(x, y): return x * y / gcd(x, y)ans = 1for x in range(2,21): ans = lcm(ans, x)print(ans)
转载于:https://www.cnblogs.com/lepeCoder/p/10992381.html