text: Composite XOR and Coprime AND | Function to return the count of odd numbers in the array ; Variable to count odd numbers ; Odd number ; Function to return the count of valid pairs ; Driver Code
code: < ? php function countOdd ( $ arr , $ n ) { $ odd = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ arr [ $ i ] % 2 == 1 ) $ odd ++ ; } return $ odd ; } function countValidPairs ( $ arr , $ n ) { $ odd = countOdd ( $ arr , $ n ) ; return ( $ odd * ( $ odd - 1 ) ) / 2 ; } $ arr = array ( 1 , 2 , 3 , 4 , 5 ) ; $ n = sizeof ( $ arr ) ; echo countValidPairs ( $ arr , $ n ) ; ? >