fibonacii with recurssion js code example
Example 1: js fibonacci sequence
// number fibonnaci to array format
function fibonacci(nums) {
let fib = [0, 1];
let data = [];
for(let i = 2; i <= nums; i++) {
fib[i] = fib[i - 1] + fib[i - 2];
data.push(fib[i]);
}
return data;
}
Example 2: javascript recursive function for fibonacci series
Enter the number of terms: 12
0
1
1
2
3