# Computing Fibonacci Sequence

In this lesson, we will learn how to compute the Fibonacci sequence using recursion.

# What is a Fibonacci Sequence?

The Fibonacci sequence is one of the most famous formulas in mathematics. Each number in the sequence is the sum of the two numbers that precede it.

So, the sequence goes:

$ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 … $

### Generic Mathematical Notation

Any number, at position n in the series, can be calculated using the following equation:

$F$_{n} $=F$_{n-2}$+F$_{n-1}

By default, the first and second number in the sequence are 0 and 1

$F$_{1} $= 0$

$F$_{2} $= 1$

$F$_{3} $=F$_{1}$+F$_{2}
$=1 + 0= 1$

$F$_{4} $=F$_{2}$+F$_{3}
$=1 + 1= 2$

$F$_{5} $=F$_{3}$+F$_{4}
$=1 + 2= 3$

$F$_{6} $=F$_{4}$+F$_{5}
$=2 + 3= 5$

$F$_{7} $=F$_{5}$+F$_{6}
$=3 + 5= 8$

$F$_{8} $=F$_{6}$+F$_{7}
$=5 + 8= 13$

Below is a visualization for the computation of the first eight elements in the Fibonacci sequence:

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