题目 求1+2+3+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 思路 递归n = 1时,返回bool 1;n >= 1时,返回n + [1,2,3…n-1]的和。 代码 # -*- coding:utf-8 -*- class Solution: def Sum_Solution(self, n): return n == 1 or self.Sum_Solution(n-1) + n