Given an integer value n, find out the n-th positive integer whose sum is 10.
Input : n = 2 Output : 28 The first number with sum of digits as 10 is 19. Second number is 28. Input : 15 Output : 154
Method 1 (Simple):
We traverse through all numbers. For every number, we find sum of digits. We stop when we find n-th number with sum of digits as 10.
Method 2 (Efficient):
If we take a closer look, we can notice that all multiples of 9 are present in arithmetic progression 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, ….
However, there are numbers in above series whose sum of digits is not 9, for example, 100. So instead of checking one by one, we start with 19 and increment by 9.
- Minimum number of digits to be removed so that no two consecutive digits are same
- 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
- Smallest number with given sum of digits and sum of square of digits
- Number of digits in the nth number made of given four digits
- Number of digits to be removed to make a number divisible by 3
- Print a number strictly less than a given number such that all its digits are distinct.
- Find count of digits in a number that divide the number
- Count number of digits after decimal on dividing a number
- Build Lowest Number by Removing n digits from a given number
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Find the smallest number whose digits multiply to a given number n
- Find maximum number that can be formed using digits of a given number
- Round-off a number to a given number of significant digits
- Check if a number with even number of digits is palindrome or not
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.