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

# Power Of Two Integers

Given a positive integer which fits in a 32 bit signed integer, find if it can be expressed as A^P where P > 1 and A > 0. A and P both should be integers.

**Example**

```
Input : 4
Output : True  
as 2^2 = 4. 
```

```java
public class Solution {
    public int isPower(int A) {
        if (A == 1)
            return 1;
        if (A <= 3)
            return 0;
        for (int i = 2; i * i <= A; i++) {
            int pow = (int) (Math.log(A) / Math.log(i));
            if (Math.pow(i, pow) == A)
                return 1;
        }
        return 0;
    }
}
```
