Python最小公倍数

def f(a, b):
    if a > b:
        greater = a
    else:
        greater = b

    while True:
        if greater % a == 0 and greater % b == 0:
            return greater
        greater += 1

print("%d是最小公倍数" % f(12, 18))

你可能感兴趣的:(Python最小公倍数)