Created
March 28, 2021 21:43
-
-
Save MateusStanki/482e136e57af74d345b1e6c9e3c825f3 to your computer and use it in GitHub Desktop.
O(n) fibonacci
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
const Fibonacci = (index) => { | |
const fibIteration = (last, beforeLast, indexCount) => | |
indexCount === 0 | |
? beforeLast | |
: fibIteration(last + beforeLast, last, indexCount - 1); | |
return fibIteration(1, 0, index); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment