For a given positive integer N, you need to calculate S = 1! +2! +3! + ... + N !.
Input format:
input line in a given positive integer of not more than 10 N.
Output format:
output value S in a row.
Sample input:
3
Sample output:
9
#include <stdio.h>
int main()
{
int s=0,n,i=1,x=1;
scanf("%d",&n);
while(i<=n){
s=s+x;
x=x*(i+1);
i++;
}
printf("%d",s);
return 0;
}