183k views
0 votes
Write the code in python to ask the user to input two integers. Your program will then print the greatest common divisor of the two integers. Look at the math module for a function that will help you find the greatest common divisor.

User Argenis
by
4.5k points

1 Answer

7 votes

import math

num1 = int(input("Enter a number: "))

num2 = int(input("Enter a number: "))

print(math.gcd(num1, num2))

The gcd() - greatest common divisor function, which is part of the math module works perfectly in this situation.

User Jordi Cabot
by
4.9k points