121. C Program to Compute the 1!/1+2!/2+3!/3+ 4!/4+…………+n series.
How does this program work?
- This program is used to compute the sum of series for the given order.
- Here we are going to find the series for 1!/1+2!/2+3!/3+ 4!/4+ …………………+n upto nth term.
- where The nth term is the user input.
- Computing the given series is easy by Using the simple for loop condition.
Here is the code
#include <stdio.h>
int main(void)
{
int n,sum = 0,i,h=1;
printf("Enter series of number\n");
scanf("%d",&n);
for (i=1; i<= n; i++)
{
h=h*i;
sum=(sum+h)/i;
}
printf("for series of 1!/1+2!/2+3!/3+ 4!/4+......+n!/n numbers n=%d sum of series= %d",n,sum);
return 0;
}