Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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;
}
Source by www.mathsisfun.com #
 
PREVIOUS NEXT
Tagged: #fibonacci #sequence
ADD COMMENT
Topic
Name
5+9 =