Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson14-diy1
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
c4c2a2fb
authored
Apr 22, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
8616a667
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
classes.py
classes.py
View file @
c4c2a2fb
'''
#猴子吃桃
def p(d):
#出口
if d==10:
def
f
(
n
):
if
n
==
10
:
return
1
n = (p(d
+1)+1)*2
return
n
res = p(6
)
print(
res
)
s
=
(
f
(
n
+
1
)
+
1
)
*
2
return
s
a
=
f
(
8
)
print
(
a
)
#实现1+2+3+...+num的累加和
#出口 1
def s_n(n):
if n==1:
#实现1+2+3+....+num的累计和
def
sum_number
(
number
):
if
number
==
1
:
return
1
temp = s
_n(n
-1)
v = n+temp
temp
=
s
um_number
(
number
-
1
)
v
=
n
umber
+
temp
return
v
res = s_n
(3)
print(
res
)
b
=
sum_number
(
3
)
print
(
b
)
#兔子数量
#
斐波那契数列:
兔子数量
def
f
(
n
):
if
n
<=
2
:
return
1
v
=
f
(
n
-
1
)
+
f
(
n
-
2
)
return
v
r = f(20)
print(r)
'''
res
=
f
(
20
)
print
(
res
)
#
求阶乘 5!
= 5*4*3*2*1
def
f
(
x
):
#
5!
= 5*4*3*2*1
def
f
n
(
x
):
if
x
==
0
:
return
0
elif
x
==
1
:
return
1
else
:
y
=
x
*
f
(
x
-
1
)
y
=
x
*
fn
(
x
-
1
)
return
y
r
=
f
(
5
)
print
(
r
)
c
=
fn
(
5
)
print
(
c
)
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