Recursion & Recursive Thinking
📋 What it is
Recursion is when a function calls itself to solve a smaller version of the same problem, until a base case stops it.
🗣️ Coach says
RECURSION is a mind-bending trick: a function that CALLS ITSELF on a smaller piece of the problem. Like Russian dolls, it keeps opening a smaller version until it hits the smallest ("base case") that's easy to solve. Every recursion needs a base case, or it never stops — a common bug.
🧠 Memory hook
A function calls itself on a smaller problem, until a base case stops it. Always need a base case.
😂 Giggle
How do trees access the internet?
They log in!
😲 Whoa!
To understand recursion, you must first understand recursion — the classic programmer joke, because that's literally how it works: the same idea, one level smaller.
✅ Quick check: What must every recursive function have to avoid running forever?
Say your answer out loud first — then reveal.
A base case — the smallest, simplest version it can solve directly, which stops the self-calls; without it, recursion never ends.
The base case terminates the recursion.
🧪 Try it! (2 minutes)
Count down from 5 to 1 "recursively": say a number, then do the same for one less, stopping at 1 (the base case).