public static int power(int b, int e) {
if (e == 1) return 1;
return b * power(b, e - 1);
}What is wrong?
- A
Nothing is wrong
- B
The recursive call uses the wrong operator
- C
There is no recursive step
- Dcheck_circle
The base case should return b when e == 1, or 1 when e == 0
Explanation
Returning 1 when e == 1 makes power(b,1) = 1 instead of b. The base case should be if (e == 0) return 1; or return b when e == 1.