Recursion and the Call Stack

Where does a returned value go when several calls are waiting? What makes the calls stop, and how do code order and saved values change what reaches Output?

Recursion and the call stack
↺

Where does a returned value go?

Case 1 of 3 · Press Run, then drag each Value to its Hole until Main finishes.

Code

One call

Output

Stack

0 of 6 routine frames

Trace

No calls yet

Frames are simplified. Real return addresses are machine addresses. This stack is deliberately small; the loop comparisons do not measure running time.