Fibonacci Series Program in Python using For loop
ADVERTISEMENTS
Fibonacci series program in python using for loop. In this article, you will learn how to make a fibonacci series program in python using for loop.
Fibonacci Series Pattern
The Fibonacci series is: 1, 4, 5, 9, 14, 23, 37, 60, 97
Source Code
# Fibonacci Series Program in Python using For loop
print ("Enter the number of terms to generate the Fibonacci series::\n")
x, i, t1, t2, nt = int(input()), 1, 1, 4, 0
# x - To store the number of terms
# t1 - To store the term 1
# t2 - To store the term 2
# nt - To store the next term
print ("Fibonacci Series:: ", end = "")
for i in range(x + 1):
print (t1, end = ", ")
nt = t1 + t2;
t1 = t2
t2 = nt
print ("\n")
Output
Enter the number of terms to generate the Fibonacci series::
8
Fibonacci Series:: 1, 4, 5, 9, 14, 23, 37, 60, 97,