Skip to content

Instantly share code, notes, and snippets.

@MateusStanki
Created March 28, 2021 21:43
Show Gist options
  • Save MateusStanki/482e136e57af74d345b1e6c9e3c825f3 to your computer and use it in GitHub Desktop.
Save MateusStanki/482e136e57af74d345b1e6c9e3c825f3 to your computer and use it in GitHub Desktop.
O(n) fibonacci
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