Search⌘ K

Inefficient Recursion: Fibonacci Numbers

Explore how naive recursion calculates Fibonacci numbers inefficiently due to repeated function calls. Learn to recognize the exponential growth of redundant calculations and its impact on performance when applying recursion to this classic series.

We'll cover the following...

Inefficient recursion

Here is another classic example of recursion – calculating the nthn^{th} Fibonacci number. It turns out that this is hopelessly inefficient using pure recursion, but we will also look at a useful technique to alleviate the problem.

If you are not familiar with the Fibonacci series, it is an infinite series of numbers defined as follows:

F0F_0 = 0
F1F_1 = 1
F2F_2 = F1F_1 + F0F_0 ...