text: Count numbers with unit digit k in given range | Returns count of numbers with k as last digit . ; Driver function
code: function counLastDigitK ( low , high , k ) { let mlow = 10 * ( Math . ceil ( low / 10.0 ) ) ; let mhigh = 10 * ( Math . floor ( high / 10.0 ) ) ; let count = ( mhigh - mlow ) / 10 ; if ( high % 10 >= k ) count ++ ; if ( low % 10 <= k && ( low % 10 ) > 0 ) count ++ ; return count ; } let low = 3 , high = 35 , k = 3 ; document . write ( counLastDigitK ( low , high , k ) ) ;