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
def checkEvenPower ( n ) : NEW_LINE INDENT x = 0 NEW_LINE while ( x < n ) : NEW_LINE INDENT value = pow ( 2 , x ) NEW_LINE if ( value == n ) : NEW_LINE INDENT if ( x % 2 == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT x += 1 NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 4 NEW_LINE if checkEvenPower ( N ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT