GCD of Two Numbers in Python Using in-build Function

(Last Updated On: 29/11/2022)

Python Program to Find GCD of Two Numbers Using in-build Function

#GCD of Two Numbers in Python Using in-build Function

import math

# we are taking a number from user as input
# entered value will be converted to int from string
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
 
print("The GCD of",a ,"and", b ,"is",math.gcd(a, b))

Output:

Enter first number:24
Enter second number:15
The GCD of 24 and 15 is 3