Group all co | Java implementation to group mutually coprime numbers into one group with minimum group possible ; Function to group the mutually co - prime numbers into one group ; Loop for the numbers less than the 4 ; Integers 1 , 2 and 3 can be grouped into one group ; Consecutive even and odd numbers ; Driver Code ; Function Call
class GFG { static void mutually_coprime ( int n ) { if ( n <= 3 ) { for ( int j = 1 ; j < n + 1 ; j ++ ) System . out . print ( j + " ▁ " ) ; System . out . println ( ) ; } else { System . out . println ( "1 ▁ 2 ▁ 3" ) ; for ( int j = 4 ; j < n ; j += 2 ) { System . out . println ( j + " ▁ " + ( j + 1 ) ) ; if ( n % 2 == 0 ) System . out . println ( n ) ; } } } public static void main ( String [ ] args ) { int n = 9 ; mutually_coprime ( n ) ; } }