• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 08, 2022 |7.7K Views

Javascript Program to Print the Fibonacci Sequence

Description
Discussion

In this video, we will see Javascript Program to Print the Fibonacci Sequence. In maths, the sequence Fn of Fibonacci numbers is defined by the recurrence relation Fn = Fn- 1 Fn- 2 with seed values F0 = 0 and F1 = 1

Examples:
Input: 6th term
Output 8

Input: 7th term
Output 13

As the first Fibonacci number is 0 and the second is 1. Also, we know that the last Fibonacci number is the aggregate of n-1 and n-2 terms.

So, to get the utmost Fibonacci term we can follow
fib(1) = 0
fib(2) = 1
fib(3) = fib(2) fib(1)
fib(4) = fib(3) fib(2)
fib(n) = fib(n-1) fib(n-2)

Then we publish the Fibonacci Sequence using two different approaches
1. Using Recursion
2. Using Dynamic programming

Program to print fibonacci series in Javascript: https://www.geeksforgeeks.org/fibonacci-series-program-in-javascript/