#-*- 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)
相关文章
- 12-16python-leetcode - 342. Power of Four
- 12-16[LeetCode] 231 Power of Two && 326 Power of Three && 342 Power of Four
- 12-16【LeetCode】628. Maximum Product of Three Numbers 解题报告(Python)
- 12-16[LeetCode&Python] Problem 628. Maximum Product of Three Numbers
- 12-16【leetcode❤python】326. Power of Three
- 12-16[python语法巩固][leetcode326][Power of Three]
- 12-16LeetCode | 326. Power of Three
- 12-16Leetcode 1509. Minimum Difference Between Largest and Smallest Value in Three Moves [Python]
- 12-16Java [Leetcode 326]Power of Three
- 12-16【LeetCode】326. Power of Three 3的幂(Easy)(JAVA)