Our Blog Contain Detail about Some Technical Aspect like Programming, Blogger, Tools and Tip, Suggestion, Motivational, Health, Program in C and Java, Html

Write a program to generate sum of series 1!+2!+3!+--------------n!

Write a program to generate sum of series 1!+2!+3!+--------------n!



In order generate sum of series 1!+2!+3!+--------------n! there is need to take help of function that can able to calculate the factorial of any number 


Program in C language

#include<stdio.h>

#include<conio.h>


int fact(int n)

{


     if(n==1)

          return 1;

     else

          return n*fact(n-1);

}


void main()

{


     int n,factorial,sum=0,i;

     printf("enter a number \n");

     scanf("%d",&n);

     for(i=1;i<=n;i++)

     {

        factorial=fact(i);

        sum=sum+factorial;

     }


     printf("Sum of the given series is %d",sum);

     getch();

}


Share:

No comments:

Post a Comment

Translate

Followers

Email Subscription

Enter your email address:

Delivered by FeedBurner

Recent Posts

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.