Program to check if a number can be expressed as an even power of 2 or not | Function to check if N can be expressed as an even power of 2 ; Iterate till x is N ; If x is even then return true ; Increment x ; If N is not a power of 2 ; Driver code
function checkEvenPower ( n ) { var x = 0 ; while ( x < n ) { var value = Math . pow ( 2 , x ) ; if ( value == n ) { if ( x % 2 == 0 ) return true ; else return false ; } x ++ ; } return false ; } var N = 4 ; document . write ( ( checkEvenPower ( N ) ? " " : " " ) ) ;