Fibonacci numbers in ECMAScript
Example for versions
SpiderMonkey 1.7
This example uses recursive definition of Fibonacci numbers and is meant to be executed from web-browser.
function fibonacci(n)
{ if (n<3)
return 1;
else
return fibonacci(n-1) + fibonacci(n-2);
}
var i;
document.clear();
for (i = 1; i <= 16; i++)
document.write(fibonacci(i) + ", ");
document.write("...<br />");
Comments
]]>blog comments powered by Disqus
]]>