Tuesday , September 26 2023
Breaking News Fibonacci series Images

# How to Create and get nth Fibonacci series number?

### What is the Fibonacci series?

Fibonacci series is the series of numbers that are calculated by adding the values of the previous two numbers in the sequence. The first two numbers of the sequence are zero and one. It is also known as the golden ratio. We can represent the Fibonacci sequence as shown below.

#### Formula of Fibonacci series number

F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1 as the first two numbers of the sequence.

The integer sequence of the Fibonacci series is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233……nth

It is one of the most asked interview questions.

### Example – 1

``````function fibonacciSeries(n){
var fibonac = [0, 1];

if (n <= 2) return 1;

for (var i = 2; i <=n; i++ ){
fibonac[i] = fibonac[i-1]+fibonac[i-2];
console.log(fibonac[i]);
// Print here Fibonacci series: 1 2 3 5 8 13 21 34 55
}

return fibonac[n];
}

console.log(fibonacciSeries(10));  // Output is 55
`````` 