I am not sure why no one used dynamic programming to answer this, it's by far the most efficient way to build something on a factorial in my view.
var mem = [];
function fact(num)
{
var x = parseInt(num);
if (x == 0 || x == 1) return 1;
mem[x] = x * fact(x-1);
return mem[x];
}