Found this solution to make a factorial()
function in python, but I am having trouble with understanding 'why' it works.
The function is :
def factorial(x):
if x <= 1:
return 1
else:
return x * factorial(x-1)
I'm having trouble understanding where the actual multiplication happens?
It would seem to me, that the function would keep calling itself until it gets to 1, and returns 1. Can someone enlighten me? I'm sure I'm missing something easy.