//方法一 var factorial = function factorial(i,a){ a = a || 1; if(i<2){ return a; } // return factorial(i-1,a*i); return factorial(i-1,a*i); }; console.log(factorial(100)); //方法二 function fac(n){ return n>1? n*fac(n-1):1; } console.log(fac(100));