一加到20的阶乘求和C语言
时间: 2023-05-31 16:06:35 浏览: 125
1到20的阶乘和.c
#include <stdio.h>
int main() {
int sum = 0;
int factorial = 1;
for (int i = 1; i <= 20; i++) {
factorial *= i;
sum += factorial;
}
printf("1!+2!+3!+...+20! = %d", sum);
return 0;
}
阅读全文