Commit aa717f0c by BellCodeEditor

save project

parent 08d6194a
Showing with 8 additions and 7 deletions
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
#要求这个函数能计算1+2+3+……+num的结果 #要求这个函数能计算1+2+3+……+num的结果
def suml(num): def func(n):
if num==1: if n<=2:
return 1 return 1
sumvalue = suml(num-1)+num elif n>2:
return sumvalue value = func(n-1)+func(n-2)
sum_num=suml(9) return value
print(sum_num) result = func(24)
\ No newline at end of file print(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