The greatest common divisor, also known as GCD, is the greatest number that will, without a remainder, fully divide a pair of integers.
Now, I want you to make a program that will accept two integers and with the use of loops, print out their GCD. Make good use of conditional statements as well.
Off you go!
Input
A line containing two integers separated by a space.
6·9
Output
A line containing an integer.
3
num1, num2 = input().split()
num1= int(num1)
num2= int(num2)
for i in range(num1, 0, -1):
if num1%i == 0 and num2%i == 0:
print(i)
break
Comments
Leave a comment