Count of distinct remainders when N is divided by all the numbers from the range [ 1 , N ] | Function to return the count of distinct remainders that can be obtained when n is divided by every element from the range [ 1 , n ] ; If n is even ; If n is odd ; Driver code
function distinctRemainders ( n ) { if ( n % 2 == 0 ) return parseInt ( n / 2 ) ; return ( 1 + parseInt ( n / 2 ) ) ; } let n = 5 ; document . write ( distinctRemainders ( n ) ) ;