C language to calculate the cumulative sum of factorials

王林
Release: 2020-05-13 10:45:54
Original
9412 people have browsed it

C language to calculate the cumulative sum of factorials

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);
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template