β Computer Science
Recursion: a mirror in a mirror
See it
A function that calls itself
- Recursion = solving a problem by solving a smaller version of it.
- It needs a base case: a point where it stops calling itself.
- No base case means it never ends, like two mirrors facing each other.
Call
countdown(3)
Smaller
countdown(2)
Base case
n is 0, stop