📌  相关文章
📜  在 python 代码示例中编写一个程序来打印最多 n 个项的斐波那契数列

📅  最后修改于: 2022-03-11 14:46:57.851000             🧑  作者: Mango

代码示例1
#Learnprogramo
Number = int(input("How many terms? "))
# first two terms
First_Value, Second_Value = 0, 1
i = 0
if Number <= 0:
print("Please enter a positive integer")
elif Number == 1:
print("Fibonacci sequence upto",Number,":")
print(First_Value)
else:
print("Fibonacci sequence:")
while i < Number:
print(First_Value)
Next = First_Value + Second_Value
# update values
First_Value = Second_Value
Second_Value = Next
i += 1