Program to check if a number is divisible by any of its digits | JAva implementation of above approach ; Converting integer to string ; Traversing the string ; find the actual digit ; If the number is divisible by digits then return yes ; If no digits are dividing the number then return no ; Driver Code ; passing this number to get result function
import java . io . * ; class GFG { static String getResult ( int n ) { String st = Integer . toString ( n ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { int d = st . charAt ( i ) - 48 ; if ( n % d == 0 ) { return " Yes " ; } } return " No " ; } public static void main ( String [ ] args ) { int n = 9876543 ; System . out . println ( getResult ( n ) ) ; } }