1.2利用递归实现获取斐波拉契数列中第你个数字的值
def fibo_list(n):
if n <= 1:
return n
return (fibo_list(n-1) + fibo_list(n-2))
while True:
n = int(input("Please enter the number:"))
if n == 0:
break
for i in range(n + 1):
print(fibo_list(i), end=' ')
print("")
Please enter the number:5
0 1 1 2 3 5
Please enter the number:10
0 1 1 2 3 5 8 13 21 34 55