[Math] How many natural numbers less than $10^8$ are there, whose sum of digits equals $7$

combinatorics

How many natural numbers less than $10^8$ are there, whose sum of digits equals $7$?

I got it here.But is there any more effecient and easier way to solve than the link shows?

Best Answer

The numbers have 8 places (some of which might be zero), and there are 7 units of value to go into them. (Each place can have at most 9 units, but that's automatic since there's only 7 units total.) So it's a stars and bars problem with 7 stars and 7 bars, making $\binom{14}{7} = 3432$ such numbers.

(For example, |**|*|***|||*| would correspond to the number 02130010.)

[edited: 8 places, not 7]