Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

n = 2 ** x and x = log(n) / log(2) For n to be power of 2 x has to be an integer.

n = 2 ** x

x = log(n) / log(2)

n

x

def isPowerOfTwo(n): return n > 0 and (math.log10(n) / math.log10(2)).is_integer()

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.