Find pair with maximum GCD for integers in range 2 to N | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; void solve ( int N ) { if ( N % 2 == 0 ) { cout << N / 2 << " ▁ " << N << endl ; } else { cout << ( N - 1 ) / 2 << " ▁ " << ( N - 1 ) << endl ; } } int main ( ) { int N = 10 ; solve ( N ) ; return 0 ; }