题解 | #求1+2+3+...+n#
求1+2+3+...+n
http://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
public class Solution { public int Sum_Solution(int n) { int res =n; boolean flag=(n>0)&&(res+=Sum_Solution(n-1))>0; return res; } }
求1+2+3+...+n
http://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
public class Solution { public int Sum_Solution(int n) { int res =n; boolean flag=(n>0)&&(res+=Sum_Solution(n-1))>0; return res; } }
相关推荐