Go Back

Python program to print Fibonacci series using iteration

12/18/2021
All Articles

#python program #fibonacci series

Python program to print Fibonacci series using iteration

Python program to print Fibonacci series using iteration :

The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding numbers ones. 
The sequence starts with 0 and 1, 
and then each subsequent number is the sum of the two previous numbers. The Fibonacci series is look like  this:
 
0, 1, 2, 3, 4, 5, 6, 7,   8,   9,  10,  11, 12 
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 ...
 

Let's See the Fibonacci Program Using Recursion in python.

a = 0
b = 1
n=int(input("Enter the number of terms in the sequence: "))
print(a,b,end=" ")
while(n-2):
    c=a+b
    a,b = b,c
    print(c,end=" ")
    n=n-1

Conclusion :

The program then prints the generated Fibonacci series. 
Although straightforward, the recursive method can lose efficiency for bigger values of n because it involves repeated calculations. 
Memorization or dynamic programming techniques can be used to store interim findings and reduce the need for repeated computations.
 
This Solution is provided by Shubham mishra This article is contributed by Developer Indian team. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.Also folllow our instagram , linkedIn , Facebook , twiter account for more

Article