Answers for "fibonacci sequence order"

10

fibonacci sequence

function _fib(number) {
    if (number === 0 || number === 1) {
        return number;
    } else {
        return _fib(number - 1) + _fib(number - 2)
    }
}
Posted by: Guest on December-27-2021
1

fibonacci sequence

//x is the index number in the fibonnacci sequence. 
//The function will return that index's fibonacci value
function fib(x) {
    let a = 0;
    let b = 1;
    for (var i = 0; i < x-1; i++) {
        let c = b;
        b += a;
        a = c;
    }
    return b;
}
Posted by: Guest on August-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language