When I try to implement these recursive functions in java, and use the input (x, y) values given (5,4 and 4, 3) I get a stackoverflow error
static int gFunc(int x) {
return x + 1;
}
static int fFunc (int x, int y) {
if (y == 0) {
return 1;
}
return x * fFunc(x,y);
}
Could anyone help me solve this exercise? I don't understand what I'm doing that's wrong
static int gFunc(int x) {
return x + 1;
}
static int fFunc (int x, int y) {
if (y == 0) {
return 1;
}
return x * fFunc(x,y);
}
Could anyone help me solve this exercise? I don't understand what I'm doing that's wrong