Given an integer Y and a range [L, R], the task is to find the count of all numbers from the given range whose sum of digits is equal to Y.
Input: L = 0, R = 11, Y = 2
2 -> 2
11 -> 1 + 1 = 2
Input: L = 500, R = 1000, Y = 6
Approach: Initialize count = 0 and for every number from the range, calculate sum of it’s digits. If the digit sum is equal to Y then increment the count. Print the count in the end.
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] that end with any of the given digits
- Count numbers in range L-R that are divisible by all of its non-zero digits
- 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 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 of n digit numbers whose sum of digits equals to given sum
- Count Numbers with N digits which consists of odd number of 0's
- Count of N-digit numbers with all distinct 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 firstname.lastname@example.org. 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.