#include<iostream>
using namespace std;
int main()
{
int N;
cout << "Enter the number upto which the series is to be added: ";
cin >> N;
double fact,even,odd,total;
even=odd=0;
for( int i=1 ; i<=N ; i++ )
{
fact=1;
for( int j=i ; j>=1 ; j-- )
fact*=j;
if( i%2==0 )
even+=(1/fact);
else
odd+=(1/fact);
}
total = odd - even;
cout << "The Sum of the series is: "
<< total
<< endl;
return 0;
}
No comments:
Post a Comment