Find N distinct integers with zero sum | Function to print distinct n numbers such that their sum is 0 ; Print 2 symmetric numbers ; print a extra 0 if N is odd ; Driver code
function findNumbers ( N ) { for ( var i = 1 ; i <= N / 2 ; i ++ ) { document . write ( i + " " + - i + " " ) ; } if ( N % 2 == 1 ) document . write ( 0 ) ; } var N = 10 ; findNumbers ( N ) ;