Python Program to Print Fibonacci Series using While Loop

 Python Program to Print Fibonacci Series using While Loop


print("Fibonacci Series using while loop")

n=int(input("Enter number to display fibonacci series:"))

print(f"The {n} Fibonacci terms are:")

f1=0

f2=1 

i=1 

f3=0

while i<=n:

    i=i+1 

    f1=f2

    f2=f3

    f3=f1+f2

    print(f3)

print("End of program")

Output:

Fibonacci Series using while loop

Enter number to display Fibonacci series:5

The 5 Fibonacci terms are:

1

1

2

3

5

End of program


टिप्पणी पोस्ट करा

0 टिप्पण्या