Module: M4-R5: Internet of Things (IoT)
Chapter: Ch1 Computer Intro
The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both without leaving a remainder. The algorithm below uses the **Euclidean method** to find the GCD of two integers.
# Program to find GCD of two numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
while b != 0:
a, b = b, a % b
print("GCD is:", a)
✅ This code keeps dividing the numbers until b becomes zero.
The final value of a is the GCD.