From 11d54dca09e452311a24baa826eb298db7a83aee Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 27 Mar 2022 10:18:05 +0800 Subject: [PATCH] save project --- diy1.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/diy1.py b/diy1.py index 0735a44..bb7f2ed 100644 --- a/diy1.py +++ b/diy1.py @@ -1,5 +1,10 @@ #定义一个函数sum_numbers() #要求这个函数能接收一个名为num的整型参数 #要求这个函数能计算1+2+3+……+num的结果 - - +def sum_numbers(num): + if num==1: + return 1 + volue=sum_numbers(num-1)+num + return num+volue +res = sum_numbers(100) +print(res) \ No newline at end of file -- libgit2 0.25.0