Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson14-diy2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
86730754
authored
3 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
baaa1cce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
demo2.py
demo2.py
0 → 100644
View file @
86730754
'''
任务目标
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
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment