Platinum Partner

Fibonacci Without Loops Nor Recursions //JavaScript Function



[UPDATED CODE AND HELP CAN BE FOUND HERE]


usage


for(var i = 11; --i > -11; document.write(i, " = ", fibonacci(i), "
"));
code //+ Jonas Raoni Soares Silva //@ http://jsfromhell.com/math/fibonacci [v1.0] fibonacci = function(n){ return Math.round(Math.pow((Math.sqrt(5) + 1) / 2, Math.abs(n)) / Math.sqrt(5)) * (n < 0 && n % 2 ? -1 : 1); }; /*this one requires very few recursions fibonacci = function(n){ var x; return n < 2 ? n : n % 2 ? (x = fibonacci(n = -(-n >> 1))) * x + (x = fibonacci(n - 1)) * x : (fibonacci(n >>= 1) + 2 * fibonacci(n - 1)) * fibonacci(n); }; */
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}