Maximum number of distinct positive integers that can be used to represent N | Function to return the required count ; Driver code
function count ( n ) { return parseInt ( ( - 1 + Math . sqrt ( 1 + 8 * n ) ) / 2 ) ; } var n = 10 ; document . write ( count ( n ) ) ;