Largest number M less than N such that XOR of M and N is even | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int getM ( int n ) { if ( n == 1 ) return -1 ; else return n - 2 ; } int main ( ) { int n = 10 ; int ans = getM ( n ) ; cout << ans ; }