BOJ1934-최소공배수 (python3)

Ok Haeeun·2023년 3월 1일
0

Python3로 algorithm문풀

목록 보기
23/53

어제 했던 유클리드 호제법으로 풀면 뚝딱스

n = int(input())
i = 0
while i<n:
    gcd = 0
    n1,n2 = map(int, input().split())
    for g in range(1, max(n1,n2)+1):
        if n1%g==0 and n2%g==0:
            gcd = g
    i += 1
    print(n1*n2//gcd)

n1*n2/최대공약수=최소공배수

라는 엄청난 공식...!

활용완료.

profile
tistory에 이어서 기록합니다 👉 https://i-m-okay.tistory.com/

0개의 댓글

관련 채용 정보