326. Power of Three

来源:互联网 发布:广州能源所怎么样 知乎 编辑:程序博客网 时间:2024/06/10 13:38

Given an integer, write a function to determine if it is a power of three.


code:

class Solution(object):
    def isPowerOfThree(self, n):
        """
        :type n: int
        :rtype: bool
        """
        import math
        if n<=0:return False
        else:   
            return (math.log10(n)/math.log10(3)).is_integer()

0 0
原创粉丝点击