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

#include <stdio.h>

/* 题目如下
 * S = 1 + 2! + 3! + ... + N!
 */
int main(int argc, char *argv[])
{
    int s = 0;
    int n = 0;
    int i = 1;
    int m = 1;

    printf("Please input N :");
    if (scanf("%d",&n) == 1 ){
        while (i <= n ){        
            m *= i++;
            s += m;        
        }
        printf("The result is %d 
", s);

    }
    else 
        printf("Input Error.
");

    return 0;
}
原文地址:https://www.cnblogs.com/playerc/p/3214863.html