Given a positive integer n. The task is to find count of digits of number which evenly divides the number n.
Input : n = 12 Output : 2 1 and 2 divide 12. Input : n = 1012 Output : 3 1, 1 and 2 divide 1012.
The idea is to find each digit of the number n by modulus 10 and then check whether it divides n or not. Accordingly, increment the counter. Notice that the digit can be 0, so take care of that case.
Below is implementation of this approach:
This article is contributed by Anuj Chauhan. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count digits in given number N which divide N
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Minimum digits to be removed to make either all digits or alternating digits same
- Sum and Product of digits in a number that divide the number
- Check if all digits of a number divide it
- Divide a number into two parts such that sum of digits is maximum
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Find smallest number with given number of digits and sum of digits
- Find the Largest number with given number of digits and sum of digits
- Find smallest number with given number of digits and sum of digits under given constraints
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Find the average of k digits from the beginning and l digits from the end of the given number
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s
- Count numbers from given range having odd digits at odd places and even digits at even places
- Count number of ways to divide a number in 4 parts
- Find the number of ways to divide number into four parts such that a = c and b = d
- Count the number of ways to divide N in k groups incrementally
- Count number of ways to divide an array into two halves with same sum
- Number of digits in the nth number made of given four digits