WINDING (calls building up)
Factorial(4) → waiting for Factorial(3)
Factorial(3) → waiting for Factorial(2)
Factorial(2) → waiting for Factorial(1)
Factorial(1) → waiting for Factorial(0)
Factorial(0) → returns 1 ← BASE CASE
Each call stores: local variables, return address. Stack grows DOWNWARD on most systems.
UNWINDING (returning values)
Factorial(0) = 1
Factorial(1) = 1 × 1 = 1
Factorial(2) = 2 × 1 = 2
Factorial(3) = 3 × 2 = 6
Factorial(4) = 4 × 6 = 24 ✓
KEY EXAM POINT
Each stack frame stores a copy of all local variables and the return address. When the function returns, the frame is removed (popped from the stack). Memory is released in LIFO order.