Unit 2 Task 41 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 41: Greatest common divisor

← Back to task


One possible program:

first = int(input("First number: "))
second = int(input("Second number: "))

while second != 0:
    first, second = second, first % second

print("GCD is", first)