Count numbers whose XOR with N is equal to OR with N | Function to calculate count of numbers with XOR equals OR ; variable to store count of unset bits ; Driver code
< ? php function xorEqualsOrCount ( $ N ) { $ count = 0 ; while ( $ N > 0 ) { $ bit = $ N % 2 ; if ( $ bit == 0 ) $ count ++ ; $ N = intval ( $ N / 2 ) ; } return pow ( 2 , $ count ) ; } $ N = 7 ; echo xorEqualsOrCount ( $ N ) ; ? >