Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

C Program to generate the sum of the series 1! + 2! + 3! +-------------- n!.


#include <stdio.h>
int main()
{
	
    int n , j, k = 1 , i = 1 , fact = 1 , sum1 = 0  , sum2 = 0;
	printf("Enter the last number of the series: ");
	scanf("%d" , &n);
	
	while (k < n )
	{
		printf("%d! + " , k );
		k++ ;
		
	}
	printf("%d! " , n);
	printf("=");
	
	
	for (i = 1 ; i <= n ; i++)
	{
		for (j = i ; j <= i ; j++ )
		{
	     fact = fact * i ;
		
		}
		sum1 = sum1 + fact ;
		
	}
	
       	sum2 = sum2 + sum1 ;
	
	
	printf(" %d\n" , sum2);
	
	
	
	
	
	return 0 ;
	
	
}

No comments:

Post a Comment