编写函数nain求3!+6!+9!+12!+15!+18!+21!
时间: 2023-11-17 10:00:45 浏览: 136
C语言程序设计-编写函数求3!+6!+9!+12!+15+18!+21!;
5星 · 资源好评率100%
int main() {
int sum = 0;
for (int i = 3; i <= 21; i += 3) {
int fac = 1;
for (int j = 1; j <= i; j++) {
fac *= j;
}
sum += fac;
}
printf("%d", sum);
return 0;
}
阅读全文