Power of Four

lc 342

public class Solution {
    public boolean isPowerOfFour(int num) {
        if(num <= 0) return false;
        double a = Math.log10(num)/Math.log10(4); //log power and base 3
        return (a - Math.floor(a))==0; //check after the decimal point.
    }
}

results matching ""

    No results matching ""