Check whether XOR of all numbers in a given range is even or odd | Function to check if XOR of all numbers in range [ L , R ] is Even or Odd ; Count odd Numbers in range [ L , R ] ; Check if count of odd Numbers is even or odd ; Driver Code
< ? php function isEvenOrOdd ( $ L , $ R ) { $ oddCount = floor ( ( $ R - $ L ) / 2 ) ; if ( $ R % 2 == 1 $ L % 2 == 1 ) $ oddCount ++ ; if ( $ oddCount % 2 == 0 ) return " Even " ; else return " Odd " ; } $ L = 5 ; $ R = 15 ; echo isEvenOrOdd ( $ L , $ R ) ; ? >