> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/bit/231.-power-of-two.md).

# 231. Power of Two

<https://leetcode.com/problems/power-of-two/>

O(1), O(1)

```java
class Solution {
    public boolean isPowerOfTwo(int n) {
        return ( n > 0 && ( (n & (n-1)) == 0));
    }
}
```
