Question
To Print the GCD of two numbers.
Sample TestCaseExpected Output
Enter First number : 2 GCD is 2
Enter Second number : 4
Answer
def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
a=int(input("Enter first number : "))
b=int(input("Enter second number : "))
GCD=gcd(a,b)
print("GCD is",GCD)

No comments:
Post a Comment