36. Find the sum of multiple factorials

/*
Assignment operator (also called change operator, when these
operators appear in the expression, we have to consider that the
value of one or several variables has been changed):

=
+= x+=5; x=x+5; Accumulation
-=
*= Accumulation
/=
%= Both sides of the operation must be integers

Factorial:
5!=5*4*3*2*1
10!=10*9*8*7*6*5*4*3*2*1

*/
#include "stdio.h"
void main()
{
int n,x,sj,sum=0;

for(n=1;n<=12;n++)
{
sj=1;
for(x=n;x>=1;x--)
{
sj=sj*x;
}
sum+=sj;
}
printf("12个阶乘之和:%d\n",sum);
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325789163&siteId=291194637