#27 백준 2609번 파이썬
우보만리
- 중학교 수학시간에 배우는 최대 공약수와 최소 공배수
- python의 math 라이브러리에 최대 공약수와 최소 공배수를 구하는 함수가 구현되어있다고 한다.
math.gcd(a,b)
: 최대공약수math.lcm(a,b)
: 최소공배수 (python 3.9 버전부터 지원) - 그런데 이 정도는 그냥 짜는게 어떨지..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T = list(map(int,input().split())) | |
small, large = sorted(T) | |
# 최대 공약수 | |
## 최대 공약수는 둘 중 작은 값보다 작다 | |
for i in range(small,0,-1): | |
if small %i != 0 : | |
continue | |
if large % i == 0: | |
print(i) | |
break | |
#최소 공배수 | |
## 최소 공배수는 둘 중 큰 값보다 크다 | |
i = 0 | |
while 1: | |
i+=1 | |
temp = large * i | |
if temp % small == 0: | |
print(temp) | |
break |