Split N natural numbers into two sets having GCD of their sums greater than 1 | Function to create and print the two sets ; For n <= 2 such sets can never be formed ; Check if N is even or odd and store the element which divides the sum of N natural numbers accordingly ; First set ; Print elements of second set ; Driver code
def createSets ( n ) : NEW_LINE INDENT if ( n <= 2 ) : NEW_LINE INDENT print ( " - 1" ) ; NEW_LINE return ; NEW_LINE DEDENT else : NEW_LINE INDENT x = ( n // 2 ) if ( n % 2 == 0 ) else ( ( n + 1 ) // 2 ) ; NEW_LINE print ( x , " ▁ " ) ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( i == x ) : NEW_LINE INDENT continue ; NEW_LINE DEDENT print ( i , end = " ▁ " ) ; NEW_LINE DEDENT DEDENT return ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 7 ; NEW_LINE createSets ( N ) ; NEW_LINE DEDENT