标签:
function factorial(n) {
var product = 1, i = 2;
while (i <= n) {
product *= i;
}
return product;
}
alert(factorial(4));
function factorial(n) { var product = 1; while (n > 1) { product *= n; n--; } return product; } alert(factorial(4));
function factorial(n) { if (n <= 1) { return 1; } else { return n * factorial(n - 1); } } alert(factorial(4));
标签:
原文地址:http://www.cnblogs.com/feile/p/5323303.html