Possible two sets from first N natural numbers difference of sums as D | Function returns true if it is possible to split into two sets otherwise returns false ; Driver code
function check ( N , D ) { let temp = ( N * ( N + 1 ) ) / 2 + D ; return ( temp % 2 == 0 ) ; } let N = 5 ; let M = 7 ; if ( check ( N , M ) ) document . write ( " " ) ; else document . write ( " " ) ;