Encore Echo Theater
The dancers need four smaller encores, but one cue keeps repeating forever. Build a routine that calls itself and knows exactly when to stop!
π§ Before we start
At the Studio Switchboard, one event woke many listeners. Today one routine asks a smaller copy of itself to finish the job. This is recursion. Every recursive routine needs a base case that says βstop.β
Arrange the encore recipe
Tap the four visual instruction blocks in the order a safe recursive routine follows them.
Open the nested encore
Start with 4. Each tap opens the same routine with one smaller number. Reach the green base case at zero.
Return through the call stack
The base case finished first. Tap the paused calls from the deepest card upward so every routine can return.
Debug the endless encore
This routine performs and calls itself, but never stops. Tap the pulsing gap, then add the missing base case.
π What you learned
- Recursion happens when a routine asks a smaller copy of itself to help.
- Each call shrinks the problem so it moves toward an ending.
- The base case stops new calls when the answer is simple.
- Paused calls form a call stack and return in reverse order.
- Without a reachable base case, recursion never ends.