Ticker

6/recent/ticker-posts

Header Ads Widget

Responsive Advertisement

Power of 2 ,

CHECK IS NUMBER N IS POWER OF 2 OR NOT

// solved through bits multiplication
 bool isPowerofTwo(long long n){
           int sum=0;
           while(n!=0){
               int a=n%2;
               sum=sum*10+a;
               n=n/2;
           }
           if(sum==1){
               return true;
           }
        return false;
    } 

Post a Comment

0 Comments