Catfish2 's solution looks quite right - what are you trying to do with scanf here? It seems to me like you don't entirely understand the usage of that function (or I'm terribly mistaken myself).
In order to use Catfish2's function your program should look as such:
#include <iostream>
#include <cmath>
usingnamespace std;
//Catfish2's function
unsignedlongint your_homework(unsignedlongint n)
{
if (n == 1)
return 1;
return pow(n, n) + your_homework(n - 1);
}
int main()
{
unsignedlongint n, sum;
n = 4; //replace this value for whatever you want n to be off course
sum = your_homework(n);
cout << "sum= " << sum << endl;
return 0;
}