How to print the Fibonacci Sequence using Python?


Fibonacci series contains numbers where each number is sum of previous two numbers. This type of series is generated using looping statement.

Example

x=0
y=1
fibo=0
while fibo<10:
    fibo=fibo+1
    z=x+y
    print (z)
    x,y=y,z

Output

Above program print 10 numbers in Fibonacci series

1
2
3
5
8
13
21
34
55
89

Updated on: 21-Feb-2020

529 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements