Created
September 6, 2018 23:31
-
-
Save Kiwipup/7bc9988fa9faeb8f33c28c362eeeb1b0 to your computer and use it in GitHub Desktop.
First Factorial
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 FirstFactorial(num) { | |
// code goes here | |
//when num is finally equal to 1 or 0, the function will terminate | |
if (num === 0 || num === 1){ | |
return 1; | |
} | |
/*Multiplies the value of num by it's own value -1 each time this function loops. | |
The function will call itself over and over again until num is equal to 1.*/ | |
return num * FirstFactorial(num-1); | |
} | |
// keep this function call here | |
FirstFactorial(readline()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks good. Recursion is a good choice for this problem.