📜  斐波那契求和 javascript 代码示例

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

代码示例2
// 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;
}