Commit fd3ec42a by BellCodeEditor

save project

parent c115c0e2
Showing with 6 additions and 0 deletions
# 尝试编写func()函数输出斐波那契数列的第十五个数是什么? # 尝试编写func()函数输出斐波那契数列的第十五个数是什么?
# 斐波那契数列:1,1,2,3,5,8,13,21,34,55…… # 斐波那契数列:1,1,2,3,5,8,13,21,34,55……
def func(n): def func(n):
f=[1,1]
c=int(input('第几个数'))
for i in range(2,c+1):
f.append(f[i-2]+f[i-1])
print(f[c-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