Solution Review: Fibonacci Numbers

Let’s take a detailed look at the previous challenge’s 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).


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

Let’s look at the visual illustration for this problem.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.