# 3 的幂

判断一个数是不是3的幂

class Solution {
    public boolean isPowerOfThree(int n) {
        if (n < 1) {
            return false;
        }

        while (n % 3 == 0) {
            n /= 3;
        }

        return n == 1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().isPowerOfThree(27));
    }
}
Last Updated: 1/16/2021, 9:27:12 AM