Find whether a given number is a power of 4 or not | javascript program to check if given number is power of 4 or not ; 0 is not considered as a power of 4 ; Driver code
function logn ( n , r ) { return Math . log ( n ) / Math . log ( r ) ; } function isPowerOfFour ( n ) { if ( n == 0 ) return false ; return Math . floor ( logn ( n , 4 ) ) == Math . ceil ( logn ( n , 4 ) ) ; } let test_no = 64 ; if ( isPowerOfFour ( test_no ) ) document . write ( test_no + " " ) ; else document . write ( test_no + " " ) ;