본문 바로가기
알고리즘/백준

백준-1934번(최소공배수)-python3

by nyeongha 2023. 11. 24.
def gcd(m,n):
    if m==0 or n==0:
        return (m if n==0 else n)
    elif m>n:
        a=m%n
        return gcd(n,a)
    elif m<n:
        a=n%m
        return gcd(m,a)

for x in range(int(input())):
    a,b=map(int,input().split())
    if a==b:
        print(a)
    else:
        k=gcd(a,b)
        print((a*b)//k)