Last active
September 19, 2018 18:23
-
-
Save v1b3m/bee0cc8bbff1c2840bb64f76986f51f3 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 ) { | |
//terminate if x is less than one | |
if (n < 0) return; | |
//return base value for 1 | |
if ( n === 1 ) { | |
return 1; | |
} | |
//recur for values greater than one | |
return n * factorial( n - 1 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment