Search⌘ K
AI Features

Solution Review: Fibonacci Numbers

Explore how to calculate Fibonacci numbers using a recursive function. Understand the base case and recursive calls, examine the time complexity, and identify inefficiencies to prepare for improved solutions in later lessons.

We'll cover the following...

Solution

A Fibonacci number is calculated by adding the previous two Fibonacci numbers. At the start, we assume the first two numbers are 1 and 1. So, its formula is f(n) = f(n-1) + f(n-2).

Example

For example, the Fibonacci series is 1,1,2,3,5,8, ...