Fibonacci number

In Mathematics, the Fibonacci numbers are the numbers in the following integer sequence called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:

In Python we may write the solution like this..

#Create a list and instantiate it with 0,1

lst=[0,1]

#Run a loop for N number of times:

for i in range(20):
     lst.append(lst[-1]+lst[-2])
     print(lst)

 

Leave a Reply