Skip to content

Instantly share code, notes, and snippets.

@sanket143
Last active June 23, 2017 06:27
Show Gist options
  • Save sanket143/3a0baa0cbdabaff15a2d3097883dd687 to your computer and use it in GitHub Desktop.
Save sanket143/3a0baa0cbdabaff15a2d3097883dd687 to your computer and use it in GitHub Desktop.
To calculate factorial
function factorialize(num) {
product=1;
var fast =[];
if(num>0){
var ghr= num;
for(i=1;i<=ghr;i++){
fast.push(i);
}
for(i=0;i<fast.length;i++){
product=product*fast[i];
num = product;
}
return num;
}
else if(num===0) {
return 1;
}
else {
return "Factorial not possible";
}
}
factorialize(20);//Here goes your no. of which you want to find factorial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment