Answers for "first n even numbers sum javascript"

1

first n even numbers sum javascript

// 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;
}
Posted by: Guest on October-24-2020

Code answers related to "first n even numbers sum javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language