Maximum GCD among all pairs ( i , j ) of first N natural numbers | C ++ implementation of the above approach ; Function to find the maximum GCD among all the pairs from first n natural numbers ; Return max GCD ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int maxGCD ( int n ) { return ( n / 2 ) ; } int main ( ) { int n = 4 ; cout << maxGCD ( n ) ; return 0 ; }