<script>
function factorial(n)
{
var a = [1];
for (var i = 1; i <= n; ++i)
{
for (var j = 0, c = 0; j < a.length || c != 0; ++j)
{
var m = (j < a.length) ? (i * a[j] + c) : c;
a[j] = m % 10;
c = (m - a[j]) / 10;
}
}
return a.reverse().join("");
}
alert("7!=" + factorial(7) + "\n\n37!=" + factorial(37) + "\n\n71!=" + factorial(71) + "\n\n100!=" + factorial(100) + "\n\n150!=" + factorial(150));
</script>
posted on 2006-04-03 15:03
汪杰 阅读(158)
评论(0) 编辑 收藏 引用 所属分类:
javascript 、
hengxing网站js