Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. def isPowerOfTwo(self, n):
  2.  
  3. if n == 0:
  4. return False
  5. while n != 0:
  6. if (n & 1) == 1 and ((n >> 1) != 0):
  7. return False
  8. n = n >> 1
  9.  
  10. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement