Need Help with Simple Recursion!
I'm trying to get this simple recursion method figured out and I'm having a tough time. What this function is supposed to do is accept 2 arguments into parameters x and y and then give back the value of x times y. How do I do this?? I know I have to use addition somehow since it is recursion! Any help would be appreciated! Thanks!
Phil
Re: Need Help with Simple Recursion!
Moved from CodeBank (which is for finished code samples), and mis-post deleted.
Re: Need Help with Simple Recursion!
Code:
public static int multiply(int x, int y) {
if (y == 1) {
return x;
}
else {
return x + multiply(x, y - 1);
}
}