您的位置:首页 > 其它

最大公约数、最小公倍数

2017-02-24 23:03 225 查看

其实可以不比较数字的大小

def gcd(n_big, n_small):
'''The greatest common divisor func.'''
return bcd(n_small, n_big % n_small) if n_big % n_small > 0 else n_small

def lcm(n_big, n_small):
'''The lowest common multiple func.'''
return n_big * n_small // gcd(n_big, n_small)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: