Commit f8a4ca57 by BellCodeEditor

auto save

parent 0f53c1f3
Showing with 17 additions and 0 deletions
# 请用递归的知识实现1+2+3+...+num的累加和
def func(num):
if num == 1:
return num == 1
else:
return num + func(num - 1)
print(func(100))
\ No newline at end of file
def func(n):
if n<=2:
return 1
elif n>2:
value = func(n-1)+func(n-2)
return value
result
\ 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