https://leetcode.com/problems/power-of-two/
Given an integer, write a function to determine if it is a power of two.
水一发python。。
class Solution(object):
def isPowerOfTwo(self, n):
shift = 1
if n == 1 or n == 2:
return True
while shift < n:
shift <<= 1
return shift == n
原文:http://www.cnblogs.com/GadyPu/p/5020682.html