Sum of the series 1 ^ 1 + 2 ^ 2 + 3 ^ 3 + ... . . + n ^ n using recursion | C ++ implementation of the approach ; Recursive function to return the sum of the given series ; 1 ^ 1 = 1 ; Recursive call ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define ll  long long int NEW_LINE ll sum ( int n ) { if ( n == 1 ) return 1 ; else return ( ( ll ) pow ( n , n ) + sum ( n - 1 ) ) ; } int main ( ) { int n = 2 ; cout << sum ( n ) ; return 0 ; }