write a program to check the divisibility of a number by another number say b.using scanner
Answers
Answered by
2
Answer:
// Java implementation of above approach
class GFG
{
// Function to check if given number is divisible
// by any of its digits
static String isDivisible(int n)
{
int temp = n;
// check if any of digit divides n
while (n > 0)
{
int k = n % 10;
// check if K divides N
if (temp % k == 0)
{
return "YES";
}
n /= 10;
}
return "NO";
}
// Driver Code
public static void main(String[] args)
{
int n = 9876543;
System.out.println(isDivisible(n));
}
}
Explanation:
Hope it will help you Please mark as brainliest
Similar questions