# For how many whole numbers between 0 and 1000 does the sum of the digits equal 9 ?

Let your whole number be ‘X’. Now,
0 < X < 1000 means that your numbers are either 3 digit, 2 digit and 1 digit. We consider each case seperately.

Case 1. ( 1 digit )

I believe its obvious that only ‘9’ fits the criteria.

Case 2 ( 2 digit number )

In this case let X = ‘ab’ = 10a + b in decimal notation or base 10, where a and b are integers between 0 to 9.
so, a + b = 9 implies b = 9 – a and put this for X,
X = 10a + b
= 10a + 9 – a
= 9a + 9
= 9*( a + 1 )

In other words any ‘digit value of a’ gives a required X which is a ‘multiple of 9 form’. Let a = 1,2 … 9 to get,
X = 9* ( a + 1)
= 18, 27, 36, 45, 54, 63, 72, 81 ,90
In other words, the only two digit numbers whose sum of digits equal to ‘9’ are the ‘multiples of 9’. Note that a does not equal to zero because in that case, it will ‘degenerate’ to making X a ‘one digit number’. We have 9 two digit numbers that satisfy our problem.

Case 3 ( 3 digit number. )

X = 100a + 10b + c, in base 10 as before. We proceed similarly as in Case 2.
a + b + c = 9, thus c = 9 – a – b, so
X = 100a + 10b + ( 9 – a – b )
= 99a + 9b + 9
= 9* ( 11a + b + 1)

We see that X is a multiple of 9 again. The question is , is it all multiples of 9 or just some selected ones?

Lets proceed “slightly different”. Consider the equation :
a + b + c = 9. We count the “number of valid” solutions. We can do this because there is a “limited” range of values for which a,b, and c can take since being the digits of numbers in base 10, they are limited to values in the interval [0,9].

If a = 9, forces b=c =0. [ 1 solution here ]
If a = 8, b + c = 1, (b,c) = (1,0) or (0,1) [ 2 Solutions here ]
If a =7. b+c = 2, (b,c) = (0,1)… you can go on like this but there must be a “smarter way” to look at it instead of just listing out all possibilities…

Indeed we want to count the number of solutions for
a+b+c =9 for a,b,c in [0,9]. Instead of indulging deep into generating functions… we use the “theorem below”.

For x(1) + x(2) + … x(k) = m. where k & m are positive integers, the number of solutions in positive integers is :
C( m – 1, m – k ) = (m -1)! / [( m – k )! * ( k – 1)! ]. Note that x(1) is variable 1, x(2) is variable 2 etc.

And, n! = n x (n -1) x (n -2)x … 2 x 1

The “theorem” above only deals with “positive integers” in its indicies but we have “zero as a possible answer as well”.

Therefore we find first “positive integer solutions” and count the number “solutions which have one of a,b,c = 0” later.

Number of positive integer solutions for a+b+c=9 means that in the above, k = 3 & m = 9. Thus the number of solutions is just = C( m – 1, m – k ) = C( 8, 6 )= (m -1)! / [( m – k )! * ( k – 1)!
=[ 8! ] / [ 6! * 2! ] = 56/2 = 28. That is there are 28 solutions in positive integers implying 28 three digit numbers in this case.

What about the case where “zero is included” or equivalently, “one of a,b,c = 0?”. Since a CANNOT equal to zero ( being the first digit ), thus we have three sub cases, namely, either b = 0 or c = 0 or BOTH b AND c = 0.

Sub case 1 ( b = 0 ).
If b = 0, a + c = 9. In the theorem above, since a & c are positive integers, set m = 9 and k = 2 to obtain the total number of solutions = C( m – 1, m – k ) = C ( 8, 7 ) = 8. Thus we have 8 solutions in here yielding eight 3 – digit numbers.

Sub case 2 ( c = 0 )
If c = 0, a + b = 9. In the theorem above, since a & b are positive integers, set m = 9 and k = 2 to obtain the total number of solutions = C( m – 1, m – k ) = C ( 8, 7 ) = 8. Thus we have 8 solutions in here yielding eight 3 – digit numbers.

Sub case 3 ( b & c = 0 )
a + b + c = 9 gives, a = 9, the “only possibility”. Thus we have one solution in here.

Hence giving a total of = 8 + 8 + 1 = 17 three digit numbers when one of b & c is zero.

So, for the three digit number case we have
28 + 17 = 45 integers that satisfy our condition of the problem.

To conclude,

1 Digit number. 1 answer.
2 Digit numbers. 9 asnwers.
3 Digit numbers. 45 answers.

Total number of whole numbers between 0 and 1000 whose sum of the digits equal 9 is 1 + 9 + 45 = 55 integers.