int n = 64;
int count = 0;
while (n > 1) {
n /= 2;
count++;
}
System.out.println(count);What is printed?
- Acheck_circle
6
- B
5
- C
7
- D
64
Explanation
n: 64 -> 32 (count=1) -> 16 (2) -> 8 (3) -> 4 (4) -> 2 (5) -> 1 (6). When n=1, condition n>1 is false, exit. count = 6 (which is log2(64)).