原理
第三个数等于前面两个数之和
F(0) = 0, F(1) = 1, F(N) = F(N-1) + F(N-2)
如: 0, 1, 1, 2, 3, 5, 8, 13
代码
def fib(n):
c, a, b = 0, 0, 1
while c < n:
a, b = b, a + b #此处可以理解为 a=F(N), b=F(N+1)
c += 1
print(a, end=",")
fib(10)
输出结果:1,1,2,3,5,8,13,21,34,55,
标签:fib,13,end,数列,斐波,那契 From: https://www.cnblogs.com/gzxiaohai/p/17212826.html