Fibonacci Series Using While Loop in Python

(Last Updated On: 11/11/2022)

In this program, we write a python program to display the Fibonacci series using a while loop.

Python Program to Display Fibonacci Series Using While Loop

# Display Fibonacci Series using While Loop in Python

# we are taking a number from user as input
# entered value will be converted to int from string
n = int(input("Number of Fibonacci Series to be Printed"))
a,b = 0,1

print(a,b,end=' ')
i = 0

while(i < n-2):
  c = a + b
  print(c,end = ' ')
  a = bd
  b= c
  i = i + 1

Output:

Number of Fibonacci Series to be Printed : 10
0 1 1 2 3 5 8 13 21 34

Leave a Reply

Your email address will not be published. Required fields are marked *