Find pair with maximum GCD for integers in range 2 to N | Java program to find a pair of integers less than or equal to N such that their GCD is maximum ; Function to find the required pair whose GCD is maximum ; If N is even ; If N is odd ; Driver Code
class GFG { static void solve ( int N ) { if ( N % 2 == 0 ) { System . out . print ( N / 2 + " ▁ " + N + "NEW_LINE"); } else { System . out . print ( ( N - 1 ) / 2 + " ▁ " + ( N - 1 ) + "NEW_LINE"); } } public static void main ( String [ ] args ) { int N = 10 ; solve ( N ) ; } }