python算法学习之斐波那契数列
程序员文章站
2022-05-21 15:26:06
python算法学习之斐波那契数列
# 斐波那契
def fib(m):
n, a, b = 1, 0, 1
while n <= m:...
python算法学习之斐波那契数列
# 斐波那契 def fib(m): n, a, b = 1, 0, 1 while n <= m: print(b) a,b = b,a+b n = n +1 fib(10) 结果: 1 1 2 3 5 8 13 21 34 55