Given an integer n, the task is to find the sum of the series 11 + 22 + 33 + ….. + nn using recursion.

 Given an integer n, the task is to find the sum of the series 11 + 22 + 33 + ….. + nn using recursion.


#include <iostream>

#include <cmath>

using namespace std;

 

int series_sum(int start,int n)

{

if(start > n)

{

    return 0;

}

return pow(start,start) + series_sum(start+1,n);

}

 

int main()

{

int n;

int start = 1;

cout<<"Enter Number For Find Sum Series   =  ";

cin>>n;

cout<<"Sum of the series 1^1 + 2^2 + 3^3 + ... + "<<n<<"^"<<n<<" is "<<series_sum(1,n);

return 0;

}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.