Given an integer N, the task is to print the first N terms whose sum of digits is a multiple of 10. First few terms of the series are 19, 28, 37, 46, 55, …
Input: N = 5
Output: 19 28 37 46 55
Input: N = 10
Output: 19 28 37 46 55 64 73 82 91 109
Approach: It can be observed that to get the Nth term of the required series, find the sum of the digits of N. If the sum is already a multiple of 10 then append digit 0 in the end of N else append the minimum possible digit in the end such that the new sum of digits is a multiple of 10.
For example, to get the 19th term, since the sum of digits is already a multiple of 10 then append 0 and 190 is the 19th term of the series.
For N = 5, the minimum digit that can be appended to make the sum of digits as a multiple of 10 is 5 and 55 is the 5th term of the series.
Below is the implementation of the above approach:
19 28 37 46 55 64 73 82 91 109
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Sum of P terms of an AP if Mth and Nth terms are given
- Count all N digit numbers whose digits are multiple of X
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Sum of first n terms of a given series 3, 6, 11, .....
- Sum of first N terms of Quadratic Sequence 3 + 7 + 13 + ...
- Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + ...
- Sum of the first N terms of the series 5,12, 23, 38....
- Sum of the first N terms of the series 2,10, 30, 68,....
- Sum of the first N terms of the series 2, 6, 12, 20, 30....
- Find the sum of first N terms of the series 2*3*5, 3*5*7, 4*7*9, ...
- Minimum digits to be removed to make either all digits or alternating digits same
- Print the first N terms of the series 6, 28, 66, 120, 190, 276, ...
- Print first N terms of Lower Wythoff sequence
- Count the occurrence of Nth term in first N terms of Van Eck's sequence
- Nth number whose sum of digit is multiple of 10
- Count of n digit numbers whose sum of digits equals to given sum
- Print all n-digit numbers whose sum of digits equals to given sum
- Minimum Possible sum of digits in a positive multiple of N
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.