I hope this is not too much of a stupid question, but why does the 'return 1' statement in this Python code return the factorial of a number? This also happens for 'return True', which I understand is equivalent to 'return 1'
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
return 1does not return the factorial of a number all by itself; it depends on all the other values that have already been calculated in the recursion chain.