Program to find the greatest common divisor (GCD) of two given numbers using a while loop in Python:
# While loop in Python - Greatest Common Divisor (GCD)
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
while num2 != 0:
temp = num2
num2 = num1 % num2
num1 = temp
print("The GCD of the two given numbers is:", num1)
Comments
Post a Comment