版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/plychoz/article/details/86378800
斐波那契数列
def fab(n):
if n == 1 or n == 2:
return 1
else:
return fab(n-2)+fab(n-1)
while True:
n = input('请输入查询的数字:')
if not n.isdigit():
n = input('输入有误,请重新输入查询的数字:')
else:
break
n = int(n)
print(fab(n))