Here is the code:
#this file finds the gcd(a, b) using the euclidian algorithm
#uses the fact that, gcd(a, b) = gcd(rem(b,a), a)
def rem(a, b):
if(a - b > b):
rem(a-b, b)
return a-b
#finds the gcd of a,b. Make sure a<b.
def gcd(a, b):
if(a != 0):
gcd(rem(b, a), a)
else:
print(a, b)
return b
print(gcd(84, 126))
Here is what it outputs:
0 42
None
I'm confused because before the return statement it prints (a,b) and it prints out b as 42. But the return value on the next line is None. Can someone explain what is happening here?