Created
May 9, 2020 21:01
-
-
Save baranovxyz/333fd7b4f25b659766d1498726f42971 to your computer and use it in GitHub Desktop.
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 factorial = trampoline(function _factorial(n, acc = 1) { | |
if (n <= 1) return acc; | |
return () => _factorial(n - 1, n * acc); | |
}); | |
console.log(factorial(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment