Check if Number is a Sum of Powers of Three

这个题是看了hint, 发现如果一个十进制数字的三进制表示有2, 那么这个十进制数不是答案.

class Solution {
    public boolean checkPowersOfThree(int n) {
        while(n > 0){
            if(n % 3 == 2)
                break;
            n = n / 3;
        }
        if(n > 0)
            return false;
        return true;
    }
}