Commit 6641a283 by BellCodeEditor

save project

parent 858c54ac
Showing with 4 additions and 3 deletions
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#要求这个函数能计算1+2+3+……+num的结果 #要求这个函数能计算1+2+3+……+num的结果
def s(x): def s(x):
if x==num: if x==1:
return 1 return 1
return s(x+1)+x return s(x-1)+x
num=1 num=10
print(s(num)) print(s(num))
\ 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