c++ without loops


  • 0

    num = 4 ^ x
    x = log_4(num)
    x = log_y(num) / log_y(4)
    if x is int that means num is power of 4

    bool isPowerOfFour(int num) {
        return fmod(log10(num) / log10(4), 1) == 0;
    }
    

Log in to reply
 

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