use math function log2 and floor.

```
class Solution {
func isPowerOfTwo(_ n: Int) -> Bool {
if (n <= 0) {return false}
var m = log2(Double(n))
if floor(m) == m {
return true
}else{
return false
}
}
}
```