I have a math website http://finitehelp.com that teaches students Finite Math. I thought it would be cool to include a calculator so I made one for combinations and permutat
If you're concerned about efficiency, you'd probably want to re-implement the factorial as an iterative function rather than a recursive one. The recursive version will use a lot more memory and CPU time than the iterative version.
function factorial(n) {
var x=1;
var f=1;
while (x<=n) {
f*=x; x++;
}
return f;
}
You also shouldn't be adding your own functions to the Math namespace. It's not a good habit to get into.