# Challenge 3: The nth Fibonacci Number

Given an index, find the nth Fibonacci number.

We'll cover the following

## Problem Statement

Implement a function that takes a variable testVariable and finds the number that is placed at that index in the Fibonacci sequence.

### What is the Fibonacci Sequence?

The Fibonacci sequence is one of the most famous sequences 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 …$

Indexing starts at $0$. Therefore, at index $0$ we have the element $0$, at index $1$ we have the element $1$, at index $2$ we have the element $1$, and so on.

#### Generic Mathematical Notation of Fibonacci Sequence

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

$F$n $=F$n-2$+F$n-1

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

$F$0 $= 0$

$F$1 $= 1$

$F$2 $=F$0$+F$1 $=0 + 1= 1$

$F$3 $=F$1$+F$2 $=1 + 1= 2$

$F$4 $=F$2$+F$3 $=1 + 2= 3$

$F$5 $=F$3$+F$4 $=2 + 3= 5$

$F$6 $=F$4$+F$5 $=3 + 5= 8$

$F$7 $=F$5$+F$6 $=5 + 8= 13$

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

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