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 Tr
n == 0 is the base case of the recursive function. Factorial of 0 is 1: reference
n == 0
Once the base case returns 1, the statement return n * factorial(n-1) will have the form: return n * 1 and so on.
return n * factorial(n-1)
return n * 1