CJCoding With Joseph
15per day
← Back to Question List
Java Code Walkthrough #34

Recursion With Multiplication

mediumFunctions

📄 Code

Read carefully — what does this print?
1public class Main {
2 
3 static int mystery(int n) {
4 if (n == 1) {
5 return 2;
6 }
7 return 2 * mystery(n - 1);
8 }
9 
10 public static void main(String[] args) {
11 System.out.println(mystery(4));
12 }
13}

🎯 Your Answer