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!
Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.