Caffeinated Coder
Book an appointment
Lesson 20 · Algorithms

Recursion

A recursive function solves a problem by calling itself on a smaller copy of the same problem, until it reaches a case small enough to answer straight away. Follow fact(4) as Python stacks up one call frame per waiting call, hits the base case, then unwinds with return values. Then see Python's depth limit, the loop alternative, and why naive Fibonacci repeats work.

10 min12 steps5 questionsIntermediate
Fig 20 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.