func isPowerOfTwo(n int) bool { if n != 0 { for n & 1 == 0 { n >>= 1 } } return n == 1 }