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
function createSets ( n ) { if ( n <= 2 ) { document . write ( " " ) ; return ; } else { let x = ( n % 2 == 0 ) ? ( n / 2 ) : ( ( n + 1 ) / 2 ) ; document . write ( x + " " ) ; for ( let i = 1 ; i <= n ; i ++ ) { if ( i == x ) continue ; document . write ( i + " " ) ; } } return ; } let N = 7 ; createSets ( N ) ;