Count numbers in range L | check if the number is divisible by the digits . ; function to calculate the number of numbers ; Driver function
function check ( n ) { let m = n ; while ( n ) { let r = n % 10 ; if ( r > 0 ) if ( ( n % r ) != 0 ) return false ; n /= 10 ; } return true ; } function countIn ( l , r ) { let ans = 0 ; for ( let i = l ; i <= r ; i ++ ) if ( check ( i ) ) ans += 1 ; return ans ; } let l = 10 ; let r = 20 ; document . write ( countIn ( l , r ) ) ;