Write a python program to print Fibonacci Series using loop or recursion.

Fibonacci series is that number sequence which starts with 0 followed by 1 and rest of the following nth term is equal to (n-1)th term + (n-2)th term.

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

Recommended:

Fibonacci Series in Python using For Loop

We need to follow the following steps in order to print the Fibonacci series in Python.

  1. Input the number of terms in Fibonacci Series (n).
  2. If (n==1) then print 0, else if (n==2) print 0 and 1.
  3. else print 0, 1 and loop from 2 to n and print rest of the terms by summing up the last two fibonacci terms.

Output

Fibonacci Series in Python using Recursion

Using recursion we can only get the nth Fibonacci number at a time, therefore we need to call the recursive function for every Fibonacci term.

Output

If you have any doubts or suggestion then comment below.

Leave a Reply

Close Menu