Commit d5929468 by BellCodeEditor

auto save

parent 41d63650
Showing with 18 additions and 0 deletions
'''
任务目标
1、定义一个递归函数,函数名自取;
2、能够接收一个num的整数参数
3、函数能计算1+2+3+4....num的结果
如果定义的函数为func(num),那么func(num)=
num + func(num-1);当num等于1的时候,func(1)返回值为1
'''
def func(num):
if num == 1:
return 1
value = func(num-1)+num
print(num)
return value
print(func(5))
\ 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