Power-of-two test

A positive integer nn is a power of 2 iff n & (n - 1) == 0. Compute 16 & 15 (bitwise AND).

Show hints (2)+
  1. Write 16 and 15 in binary.
  2. A power of 2 has a single set bit.

Answer

Reveal 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.

Asked at: IMC, DRW

Related questions