Commit 53304126 by BellCodeEditor

auto save

parent eb3c76e8
Showing with 15 additions and 0 deletions
'''
任务目标
1、定义一个递归函数,函数名自取;
2、能够接收一个num的整数参数
3、函数能计算1+2+3+4....num的结果
'''
def func(num):
if num == 1:
return 1
return num+func(num-1)
print(func(100)) # 1 + 2 + 3+ 4+ 5
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