Given a number n, find whether all digits of n divide it or not.
Input : 128 Output : Yes 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Input : 130 Output : No
We want to test whether each digit is non-zero and divides the number. For example, with 128, we want to test d != 0 && 128 % d == 0 for d = 1, 2, 8. To do that, we need to iterate over each digit of the number.
Please refer complete article on Check if all digits of a number divide it for more details!
- Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Java Program for Sum the digits of a given number
- How to check if string contains only digits in Java
- Java ArrayList to print all possible words from phone digits
- Check if the given decimal number has 0 and 1 digits only
- Java Program for How to check if a given number is Fibonacci number?
- Java Program for Difference between sums of odd and even digits
- Java Program to check Armstrong Number
- Java program to check if a number is prime or not
- Java Program for efficiently print all prime factors of a given number
- TCS Coding Practice Question | Sum of Digits of a number
- Java Program to Find the Number Occurring Odd Number of Times
- Java Program to Check if count of divisors is even or odd
- Java Program to check the validity of a Password using User Defined Exception
- Java Program to Check if two Arrays are Equal or not
- Java Program to Check if a Directory is Empty or Not
- Java program to read all mobile numbers present in given file
- Java Program to print all permutations of a given string
- Java Program for Maximum size square sub-matrix with all 1s
- Java Program for Anagram Substring Search (Or Search for all permutations)