The Fibonacci series is a sequence of numbers, with the first two defined as 0 and 1, and all following numbers defined as the sum of the two previous numbers. The following python program asks a user how many Fibonacci numbers they want calculated, then calculates them.
NOTE: This site removes formatting from answers. Replace (tab) with a tab, or four spaces.
#!/usr/bin/python
print("This program finds Fibonacci numbers.")
answer = "y"
while answer == "y":
(tab)print("How many terms would you like?")
(tab)n = int(input(": "))
(tab)a = 0
(tab)b = 1
(tab)for i in range(0,n):
(tab)(tab)print(str(a) +",")
(tab)(tab)c = a + b
(tab)(tab)a = b
(tab)(tab)b = c
(tab)print("Would you like to run again? (y/n)")
(tab)answer = input(": ")
Copyright © 2026 eLLeNow.com All Rights Reserved.