Last active
June 23, 2017 06:27
-
-
Save sanket143/3a0baa0cbdabaff15a2d3097883dd687 to your computer and use it in GitHub Desktop.
To calculate 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 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