Given a range [L, R], the task is to find the count of numbers from the range whose last digit is either 2, 3 or 9.
Input: L = 1, R = 3
2 and 3 are the only valid numbers.
Input: L = 11, R = 33
Approach: Initialize a counter count = 0 and run a loop for every element from the range, if the current element ends with any of the given digits then increment the count.
Below is the implementation of the above approach:
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Count of numbers from range [L, R] whose sum of digits is Y
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3
- Count of Numbers in Range where the number does not contain more than K non zero digits
- Count numbers in range L-R that are divisible by all of its non-zero digits
- Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime
- Total numbers with no repeated digits in a range
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Count numbers with same first and last digits
- Count of numbers having only 1 set bit in the range [0, n]
- Count Odd and Even numbers in a range from L to R
- Count Numbers with N digits which consists of even number of 0’s
- Count Numbers with N digits which consists of odd number of 0's
- Count of n digit numbers whose sum of digits equals to given sum
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.
Improved By : AnkitRai01