Fibonacci Series

The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, typically starting with 0 and 1. The sequence begins as follows:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

So, the pattern is formed by adding the previous two numbers to generate the next number. Mathematically, the Fibonacci series can be defined as:

F(0) = 0
F(1) = 1
F(n) = F(n-1) + F(n-2) for n > 1


Write a program to Print 6th Fibonacci number using recursion.

    const getFibo = (n) => {
       if (n === 0) {
          return 0;
       } else if (n === 1) {
          return 1;
       }

       return getFibo(n - 1) + getFibo(n - 2);
    };
 
    // 0 1 1 2 3 5 8 13 21
    console.log(getFibo(6)) // 8