其他分享
首页 > 其他分享> > LeetCode 326. 3的幂 Power of Three

LeetCode 326. 3的幂 Power of Three

作者:互联网

 

 

class Solution {
public:
    bool isPowerOfThree(int n) {
        if (n < 1) return false;
        while (n % 3 == 0)
            n /= 3;
        return n == 1;
    }
};

 

标签:return,Power,int,isPowerOfThree,Three,Solution,326,LeetCode
来源: https://www.cnblogs.com/ZSY-blog/p/12989732.html