Python斐波那契数列
while 1:
def fib(n):
if n == 1 or n == 2:
return 1
return fib(n - 1) + fib(n - 2)
n = int(input('请输入所求数的索引:\n'))
if n == -1: # 设置跳出循环的条件
break
print('索引为%s的斐波那契数列为%s' % (n, fib(n)))