Problem :- Write A C++ Program To Find Sum Of Series 1+1/2^2+1/3^3+…..+1/n^n .
Logic :- This Below Solve this series in second ,use this statement and use it .you also can modify and see the difference
Logic :- This Below Solve this series in second ,use this statement and use it .you also can modify and see the difference
Syntax :-
Series=1/pow(i,i);
After that statement you need to add all the statement .
Solution :-
Output:-
Solution :-
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
//By-Ghanendra Yadav
double sum=0,a;
int n,i;
cout<<"1+1/2^2+1/3^3+…..+1/n^n";
cout<<"\nEnter The Value Of n :\n";
cin>>n;
for(i=1;i<=n;++i)
{
a=1/pow(i,i);
sum+=a;
}
cout<<"Sum = "<<sum<<endl<<endl;
return 0;
}
Output:-
0 Comments: