Split N natural numbers into two sets having GCD of their sums greater than 1 | Java program to split N natural numbers into two sets having GCD of their sums greater than 1 ; Function to create and print the two sets ; No such split possible for N <= 2 ; Print the first set consisting of even elements ; Print the second set consisting of odd ones ; Driver Code
class GFG { static void createSets ( int N ) { if ( N <= 2 ) { System . out . println ( " - 1" ) ; return ; } for ( int i = 2 ; i <= N ; i += 2 ) System . out . print ( i + " ▁ " ) ; System . out . print ( "NEW_LINE") ; for ( int i = 1 ; i <= N ; i += 2 ) { System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 6 ; createSets ( N ) ; } }