fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. //Catfish2's function
  7. unsigned long int your_homework(unsigned long int n)
  8. {
  9. if (n == 0)
  10. return 0;
  11.  
  12. return pow(n, n) + your_homework(n - 1);
  13. }
  14.  
  15. int main()
  16. {
  17. unsigned long int n, sum;
  18. n = 4; //replace this value for whatever you want n to be off course
  19. sum = your_homework(n);
  20. cout << "sum= " << sum << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
sum= 288