Power of Four

题目链接
就是看。这个东西对4求对数。是不是整数

public class Solution {
    public boolean isPowerOfFour(int num) {
        if (num == 0) {
            return false;
        }
        if (num == 1) {
            return true;
        }
        double result = Math.log((double)num)/Math.log(4);
        return result == Math.floor(result);
    }
}

你可能感兴趣的:(Power of Four)