Maximum GCD among all pairs ( i , j ) of first N natural numbers | Java 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
class GFG { static int maxGCD ( int n ) { return ( n / 2 ) ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . print ( maxGCD ( n ) ) ; } }