Largest number M less than N such that XOR of M and N is even | Java program for the above problem . ; Function to find the maximum possible value of M ; Edge case ; M = N - 2 is maximum possible value ; Driver code
import java . util . * ; class GFG { static int getM ( int n ) { if ( n == 1 ) return - 1 ; else return n - 2 ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . print ( getM ( n ) ) ; } }