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