Evaluating a Recursive Method
Consider the following recursive method coconut.
public int coconut(int k) {
if (k == 1) {
return 2;
} else {
return 2 * coconut(k - 1) + k;
}
}
What value is returned as a result of the call coconut(4)?
A
17
B
34
C
26
D
14
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE