Given three positive integers L, R and K.The task is to find the count of all the numbers from the range [L, R] that contains at least one digit which divides the number K.
Input: L = 5, R = 11, K = 10
5, 10 and 11 are only such numbers.
Input: L = 32, R = 38, K = 13
Approach: Initialise count = 0 and for every element in the range [L, R], check if it contains at least one digit that divides K. If yes then increment the count.
Below is the implementation of the above approach:
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 of Numbers in Range where first digit is equal to last digit of the number
- Count numbers in a range with digit sum divisible by K having first and last digit different
- Count numbers with unit digit k in given range
- Count of numbers in range which are divisible by M and have digit D at odd places
- Count of Numbers in a Range where digit d occurs exactly K times
- Count numbers divisible by K in a range with Fibonacci digit sum for Q queries
- Count of pairs (A, B) in range 1 to N such that last digit of A is equal to the first digit of B
- Count of triplets (a, b, c) in the Array such that a divides b and b divides c
- Last digit of sum of numbers in the given range in the Fibonacci series
- Count n digit numbers not having a particular digit
- Queries for count of even digit sum elements in given range using MO's Algorithm
- Queries for the count of even digit sum elements in the given range using Segment Tree.
- Queries to count integers in a range [L, R] such that their digit sum is prime and divisible by K
- Find the highest occurring digit in prime numbers in a range
- Count numbers from 1 to n that have 4 as a digit
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.