用辗转相除法计算最大公约数,再计算最小公倍数。

while True:
    try:
        a,b = map(int,input().split())
        prod=a*b
        while min(a,b)!=0:
            if a < b:
                b=b%a
            else:
                a=a%b
        print(int(prod/max(a,b)))            
    except:
        break