public class TestFac {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 20; i++) {//控制次数
int num = 1;
for (int j = 1; j <= i; j++) {//一轮执行j<=i次
num *= j;
}
sum += num;
}
System.out.println(sum);
}
}
编写Java程序求1!+2!+3!+...+20!的值??
最新推荐文章于 2023-04-18 15:59:05 发布