SHARE
TWEET

Untitled

a guest Dec 14th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #include <bits/stdc++.h>
  2.  
  3.     using namespace std;
  4.  
  5.     int power(int base, int exp) {
  6.         if(exp == 0){
  7.             return 1;
  8.         }
  9.         return base * power(base, exp - 1);
  10.     }
  11.     int sum(int n){
  12.         if(n == 1){
  13.             return power(n, n);
  14.         }
  15.         return sum(n - 1) + power(n, n);
  16.     }
  17.     int main()
  18.     {
  19.         int n;
  20.         cin >> n;
  21.         cout << sum(n) << endl;
  22.         return 0;
  23.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top