Commit baaa1cce by BellCodeEditor

auto save

parent 85e5edd8
Showing with 21 additions and 0 deletions
'''
任务目标
1、定义一个递归函数,函数名自取;
2、函数接收一个n作为参数
3、能计算出第n列斐波那契数列的值;
4、算出第几列斐波那契数列的值大于20
'''
def func(n):
if n <= 2:
return 1
else:
value = func(n-1)+func(n-2)
return value
# print(func())
i = 2
while True:
if func(i) > 20:
print('第',i,'列斐波那契数列的值大于20')
break
i += 1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment