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.
Alternate Implementation in Python
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Count digits in given number N which divide N
- Divide a number into two parts such that sum of digits is maximum
- Find count of digits in a number that divide the number
- Sum and Product of digits in a number that divide the number
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Check if the sum of digits of number is divisible by all of its digits
- Check if the given decimal number has 0 and 1 digits only
- Check if the frequency of all the digits in a number is same
- Check if the Xor of the frequency of all digits of a number N is zero or not
- Check if two numbers have same number of digits
- Check if the sum of digits of a number N divides it
- Check if a number has digits in the given Order
- Check if a number with even number of digits is palindrome or not
- Check if given number contains a digit which is the average of all other digits
- Program to check if a number is divisible by sum of its digits
- Check if a given number divides the sum of the factorials of its digits
- Check if a given number can be represented in given a no. of digits in any base
- Program to check if a given number is Lucky (all digits are different)
- Check if the number is even or odd whose digits and base (radix) is given
- Program to check if a number is divisible by any of its digits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.