Count pairs with Bitwise AND as ODD number | Function to count number of odd pairs ; variable for counting odd pairs ; find all pairs ; find AND operation check odd or even ; return number of odd pair ; Driver Code ; calling function findOddPair and print number of odd pair
< ? php function findOddPair ( & $ A , $ N ) { $ oddPair = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i ++ ) { for ( $ j = $ i + 1 ; $ j < $ N ; $ j ++ ) { if ( ( $ A [ $ i ] & $ A [ $ j ] ) % 2 != 0 ) $ oddPair = $ oddPair + 1 ; } } return $ oddPair ; } $ a = array ( 5 , 1 , 3 , 2 ) ; $ n = sizeof ( $ a ) ; echo ( findOddPair ( $ a , $ n ) ) ; ? >