Skip to content

Instantly share code, notes, and snippets.

@NEbere
Created February 11, 2016 16:19
Show Gist options
  • Save NEbere/df7336012043ed31bef2 to your computer and use it in GitHub Desktop.
Save NEbere/df7336012043ed31bef2 to your computer and use it in GitHub Desktop.
Factorisation of a digit in javascript
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