Fibonacci Series with python

lastNumber = int(input("Enter last number of series: "))
firstNumber, secondNumber = 0, 1
for i in range(0, lastNumber):
    print(firstNumber)
    firstNumber, secondNumber = secondNumber, firstNumber + secondNumber
#Output
Enter last number of series: 10
0
1
1
2
3
5
8
13
21
34

Aman Kharwal
Aman Kharwal

AI/ML Engineer | Published Author. My aim is to decode data science for the real world in the most simple words.

Articles: 2194

Leave a Reply

Discover more from AmanXai by Aman Kharwal

Subscribe now to keep reading and get access to the full archive.

Continue reading