Commit 858c54ac by BellCodeEditor

save project

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