From ee6eb3045a7c53cca0e6c474598ef6281758e9ed Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 4 Dec 2021 17:02:39 +0800 Subject: [PATCH] save project --- diy1.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/diy1.py b/diy1.py index 0735a44..57ecb99 100644 --- a/diy1.py +++ b/diy1.py @@ -1,5 +1,17 @@ #定义一个函数sum_numbers() #要求这个函数能接收一个名为num的整型参数 #要求这个函数能计算1+2+3+……+num的结果 +def snm_numbers(num): + if num == 1: + return 1 + i = snm_numbers(num-1) + p = num+i + return p +n = snm_numbers(2) +print(n) + + + + -- libgit2 0.25.0