Let me trace factorial(3) step-by-step:
Call: factorial(3)
Call: factorial(2)
Call: factorial(1)
Call: factorial(0)
Return: 1
Return: 1 × 1 = 1
Return: 2 × 1 = 2
Return: 3 × 2 = 6
Each call waits for the next to finish. They pile up on the call stack, then unwind once the base case returns. The computer keeps track of each paused function call, which is why deep recursion can cause stack overflow errors. If your recursive code crashes, the stack trace shows you exactly where it went wrong. You now understand factorial better than noobs. Let's try a different problem to lock in the pattern.