Ad
Code
Diff
  • def power_of_two( n ):
      return bin(n).count('1') == 1
    • def power_of_two( n ):
    • return n & ( n - 1 ) == 0
    • return bin(n).count('1') == 1