python实现斐波那契数列

简介: 注意不能a,b的值不能放到循环内,不然会重复1,1,2运行结果如图

a=1
b=1
c=0
print('%d,%d'%(a,b),end='')
while(c<10000):

c=a+b
(a,b)=(b,a)  #利用python中元组的特性
b=c
print(',%d'%c,end='')
目录
相关文章
|
5月前
|
Python
Python实现递归的方式来生成斐波那契数列
Python实现递归的方式来生成斐波那契数列
|
14天前
|
Python
在Python中实现斐波那契数列(Fibonacci sequence)的4中方法
在Python中实现斐波那契数列(Fibonacci sequence)的4中方法
57 0
|
4月前
|
Python
【Python 训练营】N_5 斐波那契数列
【Python 训练营】N_5 斐波那契数列
27 2
|
5月前
|
Python
python实现斐波那契数列案例代码
python实现斐波那契数列递归实现斐波那契数列:
45 0
|
算法 Python
python实现斐波那契数列的多种方式
python实现斐波那契数列的多种方式
|
5月前
|
存储 Python
Python写斐波那契数列
Python写斐波那契数列
35 0
|
5月前
|
存储 Python
用 Python 实现斐波那契数列。
【2月更文挑战第9天】【2月更文挑战第25篇】用 Python 实现斐波那契数列。
47 0
|
Python
Python实现斐波那契数列
Python实现斐波那契数列
276 0
|
Python
Python列表实现斐波那契数列
Python列表实现斐波那契数列
137 0
Python-剑指offer(7,8,9)斐波那契数列,跳台阶,变态跳台阶
Python-剑指offer(7,8,9)斐波那契数列,跳台阶,变态跳台阶