Created
April 13, 2017 15:36
-
-
Save olarclara/3ed83d1d5c7c5c6e02fd299ee1beb20f to your computer and use it in GitHub Desktop.
This file contains 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 factorial(n) { | |
if (!n) return 1; | |
return n * factorial(n-1); | |
} | |
function factorialTCO(n, partialFactorial = 1) { | |
if (!n) | |
return partialFactorial; | |
return factorialTCO(n - 1, n * partialFactorial); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment