美文网首页
326. Power of Three

326. Power of Three

作者: hyhchaos | 来源:发表于2016-12-04 19:02 被阅读9次

Java

public class Solution {
    public boolean isPowerOfThree(int n) {
        if(n<=0) return false;
        while(n>1)
        {
            if(n%3==0)
            n=n/3;
            else
            return false;
        }
        return true;
    }
}

相关文章

网友评论

      本文标题:326. Power of Three

      本文链接:https://www.haomeiwen.com/subject/foihmttx.html