Factorial not find a positive integer greater than n and

Description questions
Given a positive integer n, find no greater than the factorial of n positive integers and (i.e., demand 1! +2! +3! + ... + n!)
Input Format
A line input, comprising a positive integer n (1 <n <12).
Output Format
Output a line: factorial and.
Sample input
5
Sample Output
153
#include <stdio.h>
int main()
{
    int n,a,sum,i,j,b;
    while(scanf("%d",&n)!=EOF)
    {
        a=1; sum=0;
        for(i=1;i<=n;i++)
        {
            a=1; b=1;
            for(j=1;j<=i;j++)
            {
                b*=a;
                a++;
            }
            sum+=b;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Published 32 original articles · won praise 9 · views 70000 +

Guess you like

Origin blog.csdn.net/yi__cao/article/details/78487696