Count pairs with Bitwise XOR as EVEN number | Function to count number of even pairs ; find all pairs ; return number of even pair ; Driver Code ; calling function findEvenPair and print number of even pair
function findEvenPair ( A , N ) { let count = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 != 0 ) count ++ ; } let totalPairs = parseInt ( N * ( N - 1 ) / 2 ) ; let oddEvenPairs = count * ( N - count ) ; return totalPairs - oddEvenPairs ; } let a = [ 5 , 4 , 7 , 2 , 1 ] ; let n = a . length ; document . write ( findEvenPair ( a , n ) ) ;