public class Solution { public int Sum_Solution(int n) { //方法一短路与 /* int ans = n; boolean flag = (ans>0) && (ans+=Sum_Solution(n-1))>0; return ans;*/ //方法二求数组个数 int m = (int)Math.pow(n, 2)+n; return m>>1; } }
public class Solution { public int Sum_Solution(int n) { //方法一短路与 /* int ans = n; boolean flag = (ans>0) && (ans+=Sum_Solution(n-1))>0; return ans;*/ //方法二求数组个数 int m = (int)Math.pow(n, 2)+n; return m>>1; } }