Find the Number which contain the digit d | Returns true if d is present as digit in number x . ; Breal loop if d is present as digit ; If loop broke ; Function to display the values ; Check all numbers one by one ; Checking for digit ; Driver code
function isDigitPresent ( x , d ) { while ( x > 0 ) { if ( x % 10 == d ) break ; x = x / 10 ; } return ( x > 0 ) ; } function printNumbers ( n , d ) { for ( let i = 0 ; i <= n ; i ++ ) if ( i == d || isDigitPresent ( i , d ) ) document . write ( i + " " ) ; } let n = 47 , d = 7 ; printNumbers ( n , d ) ;