Skip to content

Instantly share code, notes, and snippets.

@juanelojga
Created August 1, 2018 02:45
Show Gist options
  • Select an option

  • Save juanelojga/a56e7fb2c2faa85bc81340e7d0d471ae to your computer and use it in GitHub Desktop.

Select an option

Save juanelojga/a56e7fb2c2faa85bc81340e7d0d471ae to your computer and use it in GitHub Desktop.
Fibonacci Sequence without TCO
function fib(n) {
if (n <= 0) return 0;
if (n === 1 || n === 2) return 1;
return fib(n - 1) + fib(n - 2);
}
console.log(fib(20000)); //ERROR: maximum call stack size exceeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment