I am using the Euclidean algorithm to find the greatest common divisor of two numbers, using recursion.
I am confused because at some point the value of b will be equal to 0, at which point I have specified that the program return the value of a, which at this point should be the greatest common divisor.
The program does not do this. Instead, I was told that I need to put a return before the gcdRecur in the else step. But why would this be necessary, since the program should exit the if statement once b == 0?
def gcdRecur(a, b):
if b == 0:
return a
else:
gcdRecur(b, a%b)
gcdRecur(60,100)