is power of 2 (Bitwise)

 bool is_pow2(int n){

        while((n/2)>0){

        int m=(n%2);

        

        //cout<<m;

        if(m==1){

            return false;

        }

        n=n/2;

        

    }

    return true;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings