GREATEST COMMON FACTOR
Write a program in python to calculate greatest common divisor of a number
import math
print("Greatest Common Divisor ")
# prints 12
print("The gcd of 60 and 48 is : ", end="")
print(math.gcd(60, 48))
# The gcd of 98 and 56 is : 14
# The gcd of 60 and 48 is : 12
'''
def hcf(a, b):
if(b == 0):
return a
else:
return hcf(b, a % b)
a = 60
b = 48
# prints 12
print("The gcd of 60 and 48 is : ", end="")
print(hcf(60, 48))
'''
Comments
Post a Comment