斐波那契数列,又称黄金分割数列,因数学家列昂纳多·斐波那契以兔子繁殖为例子而引入,故又称为“兔子数列”。
斐波那契数列指的是这样一个数列 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368…
#递归算法# def num(n):#if n < 2:# return 1#else:# return num(n-2) + num(n-1)## for i in range(20):#print(num(i),end=" ")#非递归算法# a ,b= 0,1# for i in range(20):#print(a)#a,b = b,b + a#非递归算法# a = [0,1]# for i in range(1,10):#a.append(a[i]+a[i-1] for i in range(10))# print(a)