日期0705Python练习006

2020-12-13 05:43

阅读:342

标签:app   class   range   pre   div   输入   end   练习   斐波那契数列   

斐波那契数列Fn = F[n-1] + F[n-2]

 

n = input("请输入数字")
n = int(n)
a = []
if n == 1:
    a = [0]
elif n == 2:
    a = [0,1]
else:
    a = [0,1]
    for i in range(2,n):
        a.append(a[i-1] + a[i-2])
print(a)

  

日期0705Python练习006

标签:app   class   range   pre   div   输入   end   练习   斐波那契数列   

原文地址:https://www.cnblogs.com/howiehuang/p/11147446.html


评论


亲,登录后才可以留言!