求1+2+3+...+n_JAVA_中等
求1+2+3+...+n
http://www.nowcoder.com/questionTerminal/7a0da8fc483247ff8800059e12d7caf1
// 递归处理可以累加,与操作可以代替if
public class Solution { public int Sum_Solution(int n) { int sum = n; boolean flag = n - 1 > 0 && (sum += Sum_Solution(n - 1)) > 0; return sum; } }