Solution using Log base 10 (Javascript)


  • 0
    R
    var isPowerOfTwo = function(n) {
        var res = Math.log10(n) / Math.log10(2);
        if(n <= Number.MAX_SAFE_INTEGER && (res%1) === 0)
            return true;
        else
            return false;
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.