题解 | #求1+2+3+...+n#
求1+2+3+...+n
https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
function Sum_Solution(n) { // 利用与运算短路特性实现判断 // 下面代码等价于: // if (n === 0) return 0; // n += Sum_Solution(n - 1); // return n; n && (n += Sum_Solution(n - 1)); return n; } module.exports = { Sum_Solution : Sum_Solution };