bool isPowerOfTwo(int num) {
      	if (num == 0) {
      		return false;
      	}
      	return ceil(log2(num)) == floor(log2(num));
      }
      
      Cpp language logo

      power of two

      Check if number is power of two

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.