Dremendo Tag Line

Print the fibonacci number series 1 1 2 3 5 using while loop in Python

while Loop - Question 7

In this question, we will see how to print the fibonacci number series 1 1 2 3 5 8... up to 10th term in Python programming using while loop. To know more about while loop click on the while loop lesson.

Q7) Write a program in Python to print the fibonacci number series given below using while loop.

1 1 2 3 5 8... up to 10th term

Program

i=1; n1=1; n2=0
while i<=10:
    n3=n1+n2
    print('%d ' %(n3), end='')
    n1=n2
    n2=n3

    i=i+1

Output

1 1 2 3 5 8 13 21 34 55
video-poster