剑指Offer 64 求1+2+...+n

求1+2+...+n

求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。

1 # -*- coding:utf-8 -*-
2 class Solution:
3     def Sum_Solution(self, n):
4         return n and n + self.Sum_Solution(n-1)
5         # write code here
原文地址:https://www.cnblogs.com/asenyang/p/11025176.html