标签:text proc process 等于 class ESS auto before exit
用递归函数来实现获取斐波拉契数列中第n个数字的值
ps(斐波那契数列:从3三个数开始,后一个数等于前面两个数的和:
0,1,1,2,3,5,8,13,21,34,55,89,144……
)
def add(n): if n > 2: return (add(n-1) + add(n-2)) if n == 2: return 1 if n == 1: return 0 b = int(input("请输入一个数字")) print(add(b))
结果输出:
请输入一个数字10 34 Process finished with exit code 0
标签:text proc process 等于 class ESS auto before exit
原文地址:https://www.cnblogs.com/hrv5/p/11973601.html