C++ program to find sum of series 1+1/2^2+1/3^3+…..+1/n^n

C++ program to find sum of series 1+1/2^2+1/3^3+.....+1/n^n

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

void main()
{
clrscr();
double sum=0,a;
int n,i;
cout<<“1+1/2^2+1/3^3+…..+1/n^n”;
cout<<“nEnter value of n:”;
cin>>n;

for(i=1;i<=n;++i)
{
a=1/pow(i,i);
sum+=a;
}

cout<<“Sum=”<<sum;
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *