326. Power of Three

二刷卡,不让用LOOP之类的,那就是数学方式,那就说明我肯定不会。

log3(n)= log10(n) / log10(3)..

public class Solution {
    public boolean isPowerOfThree(int n) {
        if(n < 1) return false;
        double res = Math.log10(n)/Math.log10(3);
        return res%1 == 0;
    }
}
posted @ 2016-10-21 06:54  哇呀呀..生气啦~  阅读(101)  评论(0)    收藏  举报