Here's the complete solution:
function isPowerOfTwo(n)
return n > 0 and (n & (n - 1)) = 0
This runs in time. The AND operator combines two boolean conditions: positive check and bit pattern check. Both must hold for the result to be true.