Leetcode - Power of Three

My code:

public class Solution {
    public boolean isPowerOfThree(int n) {
        return n > 0 && Math.pow(3, (int) (Math.log(Integer.MAX_VALUE) / Math.log(3))) % n == 0;
    }
}

reference:
这个解释最实用
https://discuss.leetcode.com/topic/44183/java-one-line-solution
这个解释最全面
https://leetcode.com/articles/power-of-three/

Anyway, Good luck, Richardo! — 10/14/2016

    原文作者:Richardo92
    原文地址: https://www.jianshu.com/p/3c612c5cff06
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞