# 求斐波那契数列的第 n 项 def fibo(n): if n <=2: return 1 else: return fibo(n-1) + fibo(n-2) print(fibo(10))
# 写出斐波那契数列的前 n 项 def fibo(n): a ,b = 0 ,1 ret =[] for i in range(n): ret.append(b) a , b = b , a +b return ret print(fibo(10))
posted on 2019-12-30 20:31 libra-gyf 阅读(152) 评论(0) 编辑 收藏 举报
Powered by: 博客园 Copyright © 2024 libra-gyf Powered by .NET 9.0 on Kubernetes