Skip to content
HTQHow To Quant
← Problem Bank

Power of 2?

CalcEasy~10 min· Algorithms
Problem

Given a positive integer , determine whether is a power of (i.e. for some integer ) using a single expression. No loops, no recursion, no log tables.

What is the bit pattern of a power of two, and what bit operation exploits it?