Commit 294735a8 by BellCodeEditor

auto save

parent ea716a6d
Showing with 8 additions and 6 deletions
......@@ -2,9 +2,11 @@
#要求这个函数能接收一个名为num的整型参数
#要求这个函数能计算1+2+3+……+num的结果
def sum_numbers(num):
if num == 1:
return 1
temp = sum_numbers(num - 1)
return num + temp
a=int(input())
b=a
for i in range(a):
b-=1
a=a+b
print(a)
\ No newline at end of file
result = sum_numbers(a)
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