InterviewBit - power of two integers  

by ne on 2021-09-29 under Algo tagged with interviewbit

This problem is a property of InterviewBit ( Full details of the question, and if you want to try it out yourself, proceed to interviewbit :

Here's the implementation:

public class Solution {
    public int isPower(int A) {
        if(A==1) return 1;
        int sqrm=1+(int)Math.sqrt(A);
        for(int i=2;i<=sqrm;i++){
            int n=A;
                if(n%i!=0 && n!=1) break;
                if(n==1) return 1;
        return 0;