Program to check if a number can be expressed as an even power of 2 or not | C # program for the above approach ; Function to check if N can be expressed as an even power of 2 or not ; If N is not a power of 2 ; Bitwise AND operation ; Driver Code
using System ; public class GFG { static bool checkEvenPower ( long N ) { if ( ( N & ( N - 1 ) ) != 0 ) return false ; N = N & 0x55555555 ; return ( N > 0 ) ; } public static void Main ( String [ ] args ) { long N = 4 ; Console . WriteLine ( checkEvenPower ( N ) ? 1 : 0 ) ; } }