Commit aa717f0c by BellCodeEditor

save project

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