Created
August 1, 2018 02:45
-
-
Save juanelojga/a56e7fb2c2faa85bc81340e7d0d471ae to your computer and use it in GitHub Desktop.
Fibonacci Sequence without TCO
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(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