Commit 86730754 by BellCodeEditor

auto save

parent baaa1cce
Showing with 19 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
i = 3
while True:
if func(i) > 100:
print('斐波那契数列的值大于100是第',i,'列,值是',func(12))
break
i+=1
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