计算100的阶乘
<script>
let product = 1;
for (let num = 1; num <= 100; num++) {
product *= num; //累乘100次
}
console.log(product);
</script>
计算1!+2!+3!+…+20!
<script>
let sum = 0;
for (let q = 1; q <= 20; q++) { //外层循环累加
let product = 1;
for (let i = 1; i <= q; i++) { //内层循环累积,且令i的值小于等于外层的q,做到递增
product *= i;
}
sum += product;
}
console.log(sum);
</script>
标签:product,num,let,计算,阶乘,100
From: https://www.cnblogs.com/zerotwo-zrx/p/17340664.html