【leetcode❤python】326. Power of Three
#-*- coding: UTF-8 -*-
class Solution(object):
def isPowerOfThree(self, n):
if n<=0:
return False
while True:
if n==3 or n==1:
return True
tuple=divmod(n,3)
if tuple[1]!=0:
return False
n=tuple[0]
sol=Solution()
print sol.isPowerOfThree(333)