Program to check if a number is divisible by any of its digits | Java implementation of above approach ; Function to check if given number is divisible by any of its digits ; check if any of digit divides n ; check if K divides N ; Driver Code
class GFG { static String isDivisible ( int n ) { int temp = n ; while ( n > 0 ) { int k = n % 10 ; if ( temp % k == 0 ) { return " YES " ; } n /= 10 ; } return " NO " ; } public static void main ( String [ ] args ) { int n = 9876543 ; System . out . println ( isDivisible ( n ) ) ; } }