Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

fibonacci sums javascript

// Implement a method that finds the sum of the first n
// fibonacci numbers recursively. Assume n > 0

function fibsSum(n) {
    if ( n === 1 ) {
        return 1;
    }
    if (n === 2 ) {
        return 2;
    }
    let sum = fibsSum(n-1) + n;
    return sum;
}
 
PREVIOUS NEXT
Tagged: #fibonacci #sums #javascript
ADD COMMENT
Topic
Name
3+4 =