Created
December 17, 2013 10:42
-
-
Save leoneed/8003026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fib (i) { | |
var f = 1, s = 1; | |
function recur(i, f, s) { | |
if (!i) { | |
return 1; | |
} | |
return s + recur(--i, s, f+s); | |
} | |
if (i < 4) { | |
return i >> 1; | |
} | |
i = i - 3; | |
return f + s + recur(--i, s, f+s); | |
} | |
console.log(fib(12)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment