04 Try it yourself Interactive

Push a frame, pop a frame

Step through factorial(4) one frame at a time. The stack grows downward, each frame says what it is waiting on, and a value appears in a frame the moment it is known. Then switch to fib(n) and watch one call chain turn into a branching tree. Nothing moves until you press Next.

Linear recursion
one call per level
One whole number from 0 to 6.
Press Next to begin. Each press moves one step.


      
Frame n
Depth0
Popped0
Calls0
step 0 / 0