programming-examples/js/Recursion/Write a JavaScript program to get the first n Fibonacci numbers..js
2019-11-15 12:59:38 +01:00

15 lines
277 B
JavaScript

var fibonacci_series = function (n)
{
if (n===1)
{
return [0, 1];
}
else
{
var s = fibonacci_series(n - 1);
s.push(s[s.length - 1] + s[s.length - 2]);
return s;
}
};
console.log(fibonacci_series(8));