function fib(n) {
if (n < 2){
return n
}
return fib(n - 1) + fib (n - 2)
}
int fib (int n) {
if (n < 2)
return 1;
return fib(n-1) + fib(n-2);
}
let fibonacci = function(result, len) {
// result[0, 1]; considering result as an array
if(result.length >= len) {return result;} // exit recursion when limit reached.
result.push(result[result.length-2] + result[result.length-1]);
return fibonacci(result, len); //return function until limit is reach.
}