asked 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.

asked
User Argenis
by
7.9k 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.

answered
User Jordi Cabot
by
8.3k points