var fibonacci_numbers = function (x) { if (x==1) { var loop = [0, 1]; document.getElementById("output").innerHTML = loop; return loop; } else { var s = fibonacci_numbers(x - 1); s.push(s[s.length - 1] + s[s.length - 2]); document.getElementById("output").innerHTML =s; return s; } };

Fibonacci Sequence Generator