Skip to content

Instantly share code, notes, and snippets.

@gitawego
Last active December 26, 2015 05:29
Show Gist options
  • Save gitawego/7100610 to your computer and use it in GitHub Desktop.
Save gitawego/7100610 to your computer and use it in GitHub Desktop.
function fact1(x) {
if(x<=1) return 1;
else return x*fact(x-1);
}
function fact2(x){
var res=x;
while(--x){
res *= x;
}
return res;
}
//best performance
function fac1(x)
{
var r = 1;
for(var i=2;i<=x;i++)
{
r *= i;
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment