> For the complete documentation index, see [llms.txt](https://abhyas-kanaujia.gitbook.io/interviewbit-amazon/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://abhyas-kanaujia.gitbook.io/interviewbit-amazon/02-math/power-of-two-integers.md).

# Power Of Two Integers

{% embed url="<https://www.interviewbit.com/problems/power-of-two-integers/>" %}

### Using log

```cpp
inline bool isInteger(const double &x) {
    return (x - (int)x < 1e-9);
}

int Solution::isPower(int x) {
    if(x == 1)
        return true;

    int low = 2, high = sqrt(x) + 1;

    for(int A = low; A <= high; A++) {
        double P = log(x) / log(A);
        if(P > 1 && isInteger(P))
            return true;
    }

    return false;
}

```
