N1=int(input("Enter the first number: "))
N2=int(input("Enter the second number: "))
def gcd(N1, N2):
if (N1 == 0):
return N2
if (N2 == 0):
return N1
if (N1 == N2):
return N1
if (N1 > N2):
return gcd(N1-N2, N2)
return gcd(N1, N2-N1)
if(gcd(N1, N2)):
print('GCD of', N1, 'and', N2, 'is', gcd(N1, N2))
else:
print('not found')
Comments
Leave a comment