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
function xorEqualsOrCount ( N ) { let count = 0 ; let bit ; while ( N > 0 ) { bit = N % 2 ; if ( bit == 0 ) count ++ ; N = parseInt ( N / 2 ) ; } return Math . pow ( 2 , count ) ; } let N = 7 ; document . write ( xorEqualsOrCount ( N ) ) ;