← Interval & Math
Interval & Math Target: 5s
Powers of two have exactly one set bit. n & (n-1) clears the lowest set bit — if the result is zero, only one bit was set.
def is_power_of_two(n): return n > 0 and (n & (n - 1)) == 0
Type it from memory. Go.