📜  前 n 个偶数和 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:11.549000             🧑  作者: Mango

代码示例1
// return the sum of the first n even numbers recursively. Assume n > 0

function firstEvenNumbersSum(n) {
    if (n === 0) {
        return 0;
    }
    let num = (n * 2);
    let sum = num + firstEvenNumbersSum(n-1)
    return sum;
}