Leetcode 326 Power of Three
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
1162261467 = 3^19为int范围内最大, 如果一个数为3的n方,则该数需要能被这个最大的数整除。
class Solution(object): def isPowerOfThree(self, n): return n>0 and 1162261467%n==0