I'm new to python and I tried creating a GCD function using Eucliean's Algorithm. But any time I try to print the answer, it returns none. May someone let me know what I'm doing wrong.
Code:
def gcd(a,b):
if a - b != 0:
b = b - a
b = abs(b)
if a > b:
a,b = b, a
return gcd(a,b)
else:
gcd(a,b)
else:
print(a)
x = input("Give First Num... ")
y = input("Give Second Num... ")
answer = gcd(int(x), int(y))
print("GCD = {}".format(answer))
Console:
120
GCD = None