- Joined
- Mar 19, 2009
Ok so a friend of mine got stuck with some homework, and then i got stuck too trying to help him
the problem is the following.
Implement a function "sum" in c++ defined like this
Sum(0,y) = y for all positive Y
Sum(x,y) = Sum(x-1,1) + Sum(x-1,2) + Sum(x-1,3) + . . . + Sum(x-1,y) for all positive Ys and Xs
here are some of the possible results;
Sum(1,3) = 6
Sum(2,3) = 10
Sum(4,10) = 2002
I am utterly lost as I am really not getting it, can someone shed some light on it please?
the problem is the following.
Implement a function "sum" in c++ defined like this
Sum(0,y) = y for all positive Y
Sum(x,y) = Sum(x-1,1) + Sum(x-1,2) + Sum(x-1,3) + . . . + Sum(x-1,y) for all positive Ys and Xs
here are some of the possible results;
Sum(1,3) = 6
Sum(2,3) = 10
Sum(4,10) = 2002
I am utterly lost as I am really not getting it, can someone shed some light on it please?