题解 |#求1+2+3+...+n#异常捕获模拟if语句
求1+2+3+...+n
https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
import java.util.*; public class Solution { int[] a = {0}; public int Sum_Solution(int n) { try{ a[n-1] = 1; return 1; } catch (Exception e){ return n+Sum_Solution(n-1); } } }