Recursion
Watch the call stack grow, shrink, and finally make sense.
Start the module
1. Recursion Basics · 5 min
0 of 8 lessons · 0% complete
Recursion visualizer
Every lesson in this module opens with an animation you can step through. This is the first one — Recursion Basics: A function that solves a smaller copy of itself.
Recursion Basics
Step 1 of 9
depth0base casen == 0
frames alive
countdown(3)
countdown(2)
countdown(1)
countdown(0)
countdown(0)
countdown(-1)
printed
3
2
1
liftoff
-1
A recursive function needs two parts: a base case that answers directly, and a step that makes the problem smaller.
- Lessons
- 8
- Minutes
- 45
- Problems
- 14
- Concepts
- 7
Quiz yourself: 3 questions from this module
1 / 3