How many natural numbers below 1 million have their sum of digits equal to 18?
One way to solve this would be to make all possible cases in which the digits of the no. add up to 18 and then permute them as well as repeat this process for 1-digit, 2-digit... up till 6-digit.....but obviously thats a very cumbersome way to solve this problem. Anyone can help me out with a shorter solution?
Thanks in advance!!
You can use a stars and bars approach to count the total number of (ordered) ways to add six numbers (possibly including zero) totaling $18$, then subtract $6$ times the number of ways to add six numbers totaling $8$ (thus removing the cases where one of the numbers is $\ge 10$).