用递归的方法写一个求和函数

def sum(alist):

    first,*other=alist

    return first+sum(other) if other else first


print ( sum(range(1,101)) )


'''

输出:5050

'''

你可能感兴趣的:(用递归的方法写一个求和函数)