Print digits for each array element that does not divide any digit of that element | Java program for the above approach ; 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
import java . io . * ; import java . util . * ; class GFG { static void indivisibleDigits ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + " : ▁ " ) ; for ( int j = 2 ; j < 10 ; j ++ ) { int temp = arr [ i ] ; boolean flag = true ; while ( temp > 0 ) { if ( ( temp % 10 ) != 0 && ( temp % 10 ) % j == 0 ) { flag = false ; break ; } temp /= 10 ; } if ( flag ) { System . out . print ( j + " ▁ " ) ; } } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 4162 , 1152 , 99842 } ; int N = arr . length ; indivisibleDigits ( arr , N ) ; } }