def power_of_two( x ): if x == 1: return True n = 2 power = 1 numb = 0 while numb <= x: numb = n**power if numb == x: return True power+=1 return False
def power_of_two( n ):return n & ( n - 1 ) == 0- def power_of_two( x ):
- if x == 1:
- return True
- n = 2
- power = 1
- numb = 0
- while numb <= x:
- numb = n**power
- if numb == x:
- return True
- power+=1
- return False