log(n) solution:

```
def isPowerOfTwo(self, n):
if n <= 0:
return False
while n % 2 == 0:
n = n / 2
return n == 1
```

n solution:

```
def isPowerOfTwo(self, n):
if n <= 0:
return False
if n & (n-1) == 0:
return True
return False
```