C Program Sum Factorial Series
/* C program to calculate and print sum of the series 1!+2!+3!+...+n! C program to print the sum of factorials of natural numbers from 1 to n. */ #include<stdio.h> int main() { int i,n,sum; long fact=1; printf("Enter the value of n: "); scanf("%d",&n); sum=0; /* loop to calculate sum from 1 to n*/ for(i=1;i<=n;i++) { fact = fact * i; sum= sum+ fact; } /*display the sum on screen*/ printf("The Sum of the series 1!+2!+3!+...+%d! is: %d\n",n,sum); return 0; }
Output
Enter the value of n: 5
The Sum of the series 1!+2!+3!+…+5! is: 153