def demo(m, n): if m > n: m, n = n, m p = m * n while m != 0: r = n % m n = m m = r return (int(p / n), n) val = demo(20, 30) print(‘最小公倍数为:‘, val[0]) print(‘最大公因数为:‘, val[1]) #输出结果 #最小公倍数为: 60 #最大公因数为: 10
原文地址:https://www.cnblogs.com/chuangming/p/8481035.html
时间: 2024-11-09 08:04:46