Evaluating a Recursive Method
What will be the outcome of coconut(4)?
Following is the implementation of a recursive method:
public int coconut(int k) {
if (k == 1) {
return 2;
} else {
return 2 * coconut(k - 1) + k;
}
}
What will be the outcome of coconut(4)?
A
17
B
34
C
14
D
26
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE