用c语音 2.求1!+2!+3!+…7!
时间: 2024-02-06 22:02:35 浏览: 63
01.RT红外定时器+语音提示.zip
以下是使用C语言计算1!+2!+3!+…7!的代码实现:
```c
#include <stdio.h>
int main()
{
int i, j, sum = 0, factorial = 1;
for (i = 1; i <= 7; i++) {
factorial = 1;
for (j = 1; j <= i; j++) {
factorial *= j;
}
sum += factorial;
}
printf("1!+2!+3!+...+7!=%d\n", sum);
return 0;
}
```
阅读全文