Recursive Power Method Output
What is printed when the program is executed?
public class PowerCalc {
public static int power(int base, int exponent) {
if(exponent == 0) return 1;
return base * power(base, exponent - 1);
}
public static void main(String[] args) {
System.out.println(power(3, 3));
}
}
A
9
B
27
C
81
D
3
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 2 | 0m 00s | 90 |
| #2 | richa.tuli | 1 | 1 | 0m 52s | 48 |
| #3 | lsj08030922 | 1 | 1 | 1m 52s | -12 |
| #4 | y.seong2027 | 1 | 1 | 2m 53s | -73 |
APFIVE