java/一行代码
求1+2+3+...+n
http://www.nowcoder.com/questionTerminal/7a0da8fc483247ff8800059e12d7caf1
public class Solution { public int Sum_Solution(int n) { return n == 1 ? n : n + Sum_Solution(n-1); } }
求1+2+3+...+n
http://www.nowcoder.com/questionTerminal/7a0da8fc483247ff8800059e12d7caf1
public class Solution { public int Sum_Solution(int n) { return n == 1 ? n : n + Sum_Solution(n-1); } }
相关推荐