Power-of-two test
A positive integer is a power of 2 iff n & (n - 1) == 0. Compute 16 & 15 (bitwise AND).
Show hints (2)+
- Write 16 and 15 in binary.
- A power of 2 has a single set bit.
Answer
Reveal answer →Final answer
0
Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.