Print digits for each array element that does not divide any digit of that element | Function to find digits for each array element that doesn 't divide any digit  of the that element ; Traverse the array arr ; Iterate over the range [ 2 , 9 ] ; Stores if there exists any digit in arr [ i ] which is divisible by j ; If any digit of the number is divisible by j ; If the digit j doesn 't  divide any digit of arr[i] ; Driver Code
function indivisibleDigits ( arr , N ) { for ( i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + " " ) ; for ( j = 2 ; j < 10 ; j ++ ) { var temp = arr [ i ] ; var flag = true ; while ( temp > 0 ) { if ( ( temp % 10 ) != 0 && ( temp % 10 ) % j == 0 ) { flag = false ; break ; } temp = parseInt ( temp / 10 ) ; } if ( flag ) { document . write ( j + " " ) ; } } document . write ( " " ) ; } } var arr = [ 4162 , 1152 , 99842 ] ; var N = arr . length ; indivisibleDigits ( arr , N ) ;