The following code returns None
on some values (eg 306, 136
), on some values (42, 84
), it returns the answer correctly. The print a
and return a
should yield the same result, but it does not:
def gcdIter (a,b):
c = min (a,b)
d = max (a,b)
a = c
b = d
if (b%a) == 0:
print a
return a
gcdIter (a,b%a)
print gcdIter (a,b)