函数递归调用

def summ(x):
    if x == 1:
        return 1  # x值为1时,return 1 跳出 递归调用   递归调用出口
    else:
        return x + summ(x - 1)  # 递归调用  自己调用自己

print(summ(100))
# print(summ(1000))  # Previous line repeated 986 more times  超出最大递归深度

  

posted @ 2023-05-19 15:39  sangern  阅读(14)  评论(0)    收藏  举报