Python3 斐波那契数字打印

来源:互联网 发布:linux 查看登录用户 编辑:程序博客网 时间:2024/06/11 10:38
>>> import sys>>> def fibonacci(n):a,b,counter=0,1,0while True:if (counter > n):returnyield aa,b=b,a+bcounter+=1>>> f=fibonacci(10)>>> while True:try:print(next(f),end="")except StopIteration:sys.exit()011235813213455>>> 

0 0
原创粉丝点击