Power of Two(Easy)
Given an integer, write a function to determine if it is a power of two.
Python 3 Code
class Solution:
# @param {integer} n
# @return {boolean}
def isPowerOfTwo(self, n):
return n > 0 and (n & (n - 1)) == 0
test = Solution()
print(test.isPowerOfTwo(8))