The idea
Key formulas
Factorial recurrence
Fibonacci recurrence
Loading lessons…
Just a moment, getting everything ready. The first load can take up to a minute.
Data structures and algorithms
Watch factorial and naive Fibonacci calls grow and return, revealing repeated Fibonacci work.
A recursive function solves a base case directly or calls itself on smaller input. Each call adds a frame; returning removes it. Factorial makes one recursive call per level. Naive Fibonacci branches twice, repeating the same subproblems many times.
The Fibonacci trace is intentionally capped because its call count grows exponentially. Memoization or iteration avoids recomputing the repeated subproblems.