What goes in the blank?
# is n a power of two? (one bit set) ok = n > 0 and (n & (n - 1)) == ____
Answer: 0
n - 1 flips the lowest set bit and the zeros below it; if that was the only bit, the AND is 0.
Play Problem Solving ▸
# is n a power of two? (one bit set) ok = n > 0 and (n & (n - 1)) == ____
Answer: 0