Tuesday, September 20, 2016

Power Series

Tags

Find Sum Of Any Number Powers


#include<iostream>
#include<math.h>
using namespace std;
main()
{
int num,n,sum=0;
cout<<"Enter the no whose Sum is to be calculated";
cin>>num;
cout<<"Enter Maximum Power";
cin>>n;
for(int i=1;i<=n;i++)
{
    sum=sum+pow(num,i);

}
for(int i=1;i<=n;i++)
{
    cout<<num<<"^"<<i<<"+";
}

cout<<"="<<sum;
}