一、最大公约数(greatest common divisor)

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

二、最小公倍数(least common multiple)

def lcm(a,b):
    if b==1:
        return a
    return a*b/gcd(a,b)

posted on 2019-04-11 16:48  小二妮儿  阅读(226)  评论(0编辑  收藏  举报