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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Count digits in given number N which divide N
- Find smallest possible Number from a given large Number with same count of digits
- Sum and Product of digits in a number that divide the number
- Count number of ways to divide a number in 4 parts
- Check if all digits of a number divide it
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Divide a number into two parts such that sum of digits is maximum
- Find the number of ways to divide number into four parts such that a = c and b = d
- Find smallest number with given number of digits and sum of digits under given constraints
- Count of prime digits of a Number which divides the number
- Count number of digits after decimal on dividing a number
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- 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
- Find the number of positive integers less than or equal to N that have an odd number of digits