Programming Examples
Write a Python program to find the GCD (Greatest Common Divisor) of two numbers.
Write a Python program to find the GCD (Greatest
Common Divisor) of two numbers.
[The largest number that divides both input values
without leaving a remainder]
If input is: 60 and 48 then output is: 12
Solutionnum1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
while num1 != num2:
if num1 > num2:
num1 = num1 - num2
else:
num2 = num2 - num1
print("GCD is:", num1)
Output