I need to calculate factorials for a bigger function in my spreadsheet (cdf for hypergeometric probabilities). I've tried lots of the ways that have been described in different posts here but none of them give me the correct result. If I plug in (3) I get (2) which makes no sense to me. Can anyone explain what I'm doing wrong?
Also, from what I've read I will face problems with larger factorials because JavaScript can't store very large numbers? I saw one solution suggesting I use strings to represent large integers but It looks very complicated... Any ideas on an easier way to handle this problem?.
Factorial Function:
function MyFac(x) {
var fac=x;
var i=1;
while (i<x) {
fac=fac*i;
i++;
}
return fac;
}