public static int pow(int b, int e) {
if (e == 0) return 1;
return b * pow(b, e - 1);
}
// call: pow(7, 0)What is the result?
- Acheck_circle
1
- B
7
- C
0
- D
infinite recursion
Explanation
The base case returns 1 for any exponent of 0.
AP Computer Science A· difficulty 2/5
public static int pow(int b, int e) {
if (e == 0) return 1;
return b * pow(b, e - 1);
}
// call: pow(7, 0)What is the result?
1
7
0
infinite recursion
Explanation
The base case returns 1 for any exponent of 0.
Want 10 more like this — adaptive to your weak spots?