My Project - Video Waker Alarm
Get Video alarm on Google Play

Fibonacci sequence python code


Fibonacci sequence python code. The Fibonacci sequence is a set of numbers that starts with a one or a zero, followed by a one, and proceeds the number as a sum of the preceding two numbers. As for eg : 0, 1, 2, 3, 5, 8, 13, 21, 34, 55.

fibonacci sequence python code

Fibonacci sequence python code

print('!* Fibonacci Sequence python \n')
def Fibonacci_Series():
    x = input('Enter Series length to print fibonacci sequence')

    d,e=0,1
    a = []
    a.append(d)
    a.append(e)
    while(x!=2):
        c = d + e
        d = e
        e = c
        a.append(c)
        x = x -1
    print(a)

Output:

!* Fibonacci Sequence python 

>>> Fibonacci_Series()
Enter Series length to print fibonacci sequence10
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
>>>

One thought on “Fibonacci sequence python code”

  1. d = e
    as you mentioned d=0& e=1 how could you say that both are equal.But the code is running perfectly.How could you do this

Comments are closed.