# How many 9-digit numbers are there with an even digit sum?

How many 9-digit numbers are there with an even digit sum?

How do I approach this task? I know the answer, but want to see how I need to think about solving it.

My approach to solving this was very long, mechanical and error-prone.

I noticed that the number of odd digits has to be even. And considered these scenarios:

1. 0 odd numbers, 9 even numbers
2. 2 odd numbers, 7 even numbers
3. 4 odd numbers, 5 even numbers
4. 6 odd numbers, 3 even numbers
5. 8 odd numbers, 1 even number

Then I considered 2 more cases:

This amounts to this:

1. $$4\times 5^8$$
2. $$5^9\times {8 \choose 1} + 4\times 5^8\times {8 \choose 6}$$
3. $$5^9\times {8\choose 3}+4\times5^8\times{8\choose 4}$$
4. $$5^9\times {8\choose 5}+4\times5^8\times{8\choose 2}$$
5. $$5^9\times {8\choose 7}+4\times5^8\times{8\choose 0}$$

After I added them up I got $$9\times 5\times 10^7$$.

• What is the answer? Oct 10, 2018 at 15:08
• The first digit can be any digit but zero. The next seven digits can be any digit. The last digit must match the parity of the sum of the first eight digits. Oct 10, 2018 at 15:08
• @InterstellarProbe thanks! Oct 10, 2018 at 15:10
• your number has to have an even number of odd digits, then you have to allow for the number not having leading zeroes, then it is some sort of permutation, combinations exercise - could be approached different ways - how about starting with hown many are there of format 1XXXXXXXX etc
– Cato
Oct 10, 2018 at 15:10
• @Cato the sum of digits must be even. Oct 10, 2018 at 15:12

This is of course just half of all 9-digit numbers!

To see this, think of just the last digit: since half of those are odd and half are even, that means that whatever sum you have for all the digits preceding it, half will be made even by adding the last digit, and half will be made odd.

OK, and how many 9-digit numbers are there?

Well, the first digit is 1 of 9, and for the others you have 10 choices each. Hence:

$$\frac{1}{2}\cdot 9\cdot 10^8$$

so you've got 4 different even digits you could start with, then you require 1,3,5,7 of any of the 5 evens

so that would be

$$4 \times 5 \times 5^7 \times {8\choose 1} + 4 \times 5^3 \times 5^5 \times {8\choose 3} + 4 \times 5^5 \times 5^3 \times {8\choose 5} + 4 \times 5^7 \times 5 \times {8\choose 7}$$

= 12500000 + 87500000 + 87500000 +12500000 = 200000000 - or 2oo million

then for starting with the 5 odd digits is

$$5 \times (5^8 + 5^2 \times 5^6 * {8 \choose 2} + 5^4 \times 5^4 * {8 \choose 4} + 5^2 \times 5^6 * {8 \choose 6} + 5^8 \times 5^0 * {8 \choose 0} )$$

=250000000

so there are 200 million starting with even digits and 250 million making a total of 450million

I included this for completeness, it's obviously not the simplest solution, it was what I was talking about earlier

• Thanks! Yea, this is exactly how I was thinking, but I think it's easy to make a mistake with this reasoning! (at least for me, because I'm bad at memorizing many things). Oct 11, 2018 at 13:42