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

source code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include
#include
#include
#include
 
using namespace std;
 
int main()
{
    int num,i=1;
    double fact=1,sum=0;
    cout<<"Enter number : "<
    cin>>num;cout<
 
    while(i<=num)
    {
        if(i>1)
            fact=fact*(i-1)*i;
 
        sum=sum+(1/fact);
        i=i+2;
    }
    cout<<"Sum is "<
    getch();
}