Well basically that function uses recursion to do the following:
Return the sum of all of the numbers going to 0 from the number you typed in.
So, for example
If you pass in 3, it returns 6, because 3+2+1 = 6
If you pass in 4, it returns 10, because 4+3+2+1 = 10
Etc.
The assignment wants you to write a for loop to get the same result rather than use recursion.
It's rather simple. I'm guessing you're just over complicating it.
1 2 3 4 5 6 7 8 9
int sum(int n)
{
int returnsum = 0;
for (int i = 1; i <= n; i++) //For each number counting up to 'n'
{
returnsum += i; //Add this number to our returnsum
}
return returnsum; //return our returnsum
}