递归过不了,栈太深。sum ? 或者 reduce
class Solution(object): def getSum(self, n): import functools return functools.reduce(lambda x, y: x+y, range(n+1))