Consider the following informal definition for a function calc(x,y) = (0*y) + (1*y) + … + (x*y) For example, we have that calc(2,5) = (0*5) + (1*5) + (2*5) Give a recursive definition for the function calc. Give a trace to show each step involved in calculating calc(3,4) using your definition.
I've come up with:
Base Case:
Calc(0,y) = 0
Recursive Case:
Calc(x,y) = n + Calc(x-1,y) * y
Some how I have a feeling my recursive case isn't going to work as expected.
Can somebody help me with this?