Power of Three
class Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
while n%3 == 0 and n:
n = n/3
if n == 1:
return True
return Falseclass Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
return n > 0 and (math.log10(n)/math.log10(3))%1==0Last updated
