Programming/Python & Data Structures
[Baekjoon/Python3] 4504번 배수 찾기
HooNeee
2020. 12. 4. 17:35
[Baekjoon/Python3] 4504번 배수 찾기
4504번: 배수 찾기
첫째 줄에 n이 주어진다. 다음 줄부터 한 줄에 한 개씩 목록에 들어있는 수가 주어진다. 이 수는 0보다 크고, 10,000보다 작다. 목록은 0으로 끝난다.
www.acmicpc.net
def GCD(a, b):
if b % a:
return GCD(b % a, a)
else:
return a
n = int(input())
while True:
num = int(input())
if num:
if GCD(n, num) == n:
print('%d is a multiple of %d.' %(num, n))
else:
print('%d is NOT a multiple of %d.' %(num, n))
else:
break