Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

fibonacci recursion javascript

function fibonacci(n) {
    if (n < 2){
        return 1;
    }else{
        return fibonacci(n-2) + fibonacci(n-1);
    }
}

console.log(fibonacci(7));
//Returns 21
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #fibonacci #recursion #javascript
ADD COMMENT
Topic
Name
8+8 =