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

Popular posts from this blog

Simple Python Program Code for Snake Game

Iris Flowers Classification ML Project with Code

Data exploration and scatter plot visualization in Python using Pandas and Matplotlib