Program to find sum of series “1+ 1/3! + 1/5! + 1/7! + ……………+ 1/n! “.

source code:

#include <iostream>
#include<iomanip>
#include<conio.h>
#include<math.h>

using namespace std;

int main()
{
    int num,i=1;
    double fact=1,sum=0;
    cout<<"Enter number : "<<endl;
    cin>>num;cout<<endl<<endl;

    while(i<=num)
    {
        if(i>1)
            fact=fact*(i-1)*i;

        sum=sum+(1/fact);
        i=i+2;
    }
    cout<<"Sum is "<<sum;
    getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s