The time complexity for this method is O(2^n) according to my prof.
I feel that the time complexity for this method should be O(n * 2^n) because
The outer for loop cost O(n)
The inner for loop cost O(2^n)
public static int loop(int n) {
int j = 1;
for (int i = 0; i < n; i++) {
for (int k = j; k > 0; k--) {
System.out.println("Hello world");
}
j *= 2;
}
return j;
}