Recursive Method Output
What value is printed by the Mystery program?
public class Mystery {
public static int mystery(int n) {
if(n <= 2) {
return n;
}
return mystery(n - 1) + mystery(n - 2) - mystery(n - 3);
}
public static void main(String[] args) {
System.out.println(mystery(4));
}
}
A
2
B
4
C
5
D
3
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE