Largest number M less than N such that XOR of M and N is even | Function to find the maximum possible value of M ; Edge case ; M = N - 2 is maximum possible value ; Driver code
function getM ( n ) { if ( n == 1 ) return - 1 ; else return n - 2 ; } var n = 10 ; document . write ( getM ( n ) ) ;