Specific code:
# include "stdio.h" void main() { int n,i,j,sum=0,t=1; printf("please enter a number:"); scanf("%d",&n); for(i=0;i<n;t=1,i++) //这里的循环事件是重点!每循环一次重新给t赋值。 { for(j=n-i;j>0;j--) { t*=j; } sum+=t; } printf("\n1!+....+%d!=%d",n,sum); }
Recommended tutorial: c language tutorial
The above is the detailed content of C language to calculate the cumulative sum of factorials. For more information, please follow other related articles on the PHP Chinese website!