Last active
December 31, 2015 00:18
-
-
Save RSNara/6abb2946295dbb0598b9 to your computer and use it in GitHub Desktop.
Tail-recursive Fibonacci!
This file contains 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 fibonacci(n) { | |
return (function loop(i, f0, f1) { | |
return i === 0 ? f0 : loop(i - 1, f1, f0 + f1); | |
})(n, 0, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment