c 语言练习__求到N的阶乘的和。

时间:2025-03-07 11:37:44
#include <stdio.h>

/* 题目如下
* S = 1 + 2! + 3! + ... + N!
*/
int main(int argc, char *argv[])
{
int s = ;
int n = ;
int i = ;
int m = ; printf("Please input N :");
if (scanf("%d",&n) == ){
while (i <= n ){
m *= i++;
s += m;
}
printf("The result is %d \n", s); }
else
printf("Input Error.\n"); return ;
}

相关文章