Check whether XOR of all numbers in a given range is even or odd | Java program to check if XOR of all numbers in range [ L , R ] 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
class GFG { static String isEvenOrOdd ( int L , int R ) { int oddCount = ( R - L ) / 2 ; if ( R % 2 == 1 L % 2 == 1 ) oddCount ++ ; if ( oddCount % 2 == 0 ) return " Even " ; else return " Odd " ; } public static void main ( String [ ] args ) { int L = 5 , R = 15 ; System . out . println ( isEvenOrOdd ( L , R ) ) ; } }