CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Recursion With Multiplication

Java code walkthrough · Question 34
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