Created
February 11, 2016 16:19
-
-
Save NEbere/df7336012043ed31bef2 to your computer and use it in GitHub Desktop.
Factorisation of a digit in javascript
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 factorialize(num) { | |
//check if num == 0 | |
if (num === 0) { | |
return 1; | |
} | |
//else calculate factorial | |
return num * factorialize(num - 1); | |
} | |
//calling the function. this will return 120 | |
factorialize(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment