> For the complete documentation index, see [llms.txt](https://bhabs.gitbook.io/prepbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bhabs.gitbook.io/prepbook/coding/power-of-2.md).

# Power of 2

Given an integer, write a function to determine if it is a power of two.

```
class Solution(object):
    def isPowerOfTwo(self, n):
        """
        :type n: int
        :rtype: bool
        """
        if n == 0:
            return False

        return n & (n - 1) == 0
```
