求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)

相关文章:

  • 2022-02-15
  • 2022-01-13
  • 2021-08-14
  • 2022-01-02
  • 2021-08-24
  • 2021-04-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-11
  • 2022-02-14
  • 2021-10-03
  • 2021-08-08
  • 2021-06-14
  • 2022-03-03
  • 2021-09-12
相关资源
相似解决方案