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:
- 0 odd numbers, 9 even numbers
- 2 odd numbers, 7 even numbers
- 4 odd numbers, 5 even numbers
- 6 odd numbers, 3 even numbers
- 8 odd numbers, 1 even number
Then I considered 2 more cases:
- The number can start with an odd digit.
- The number can start with an even digit.
This amounts to this:
- $4\times 5^8$
- $5^9\times {8 \choose 1} + 4\times 5^8\times {8 \choose 6}$
- $5^9\times {8\choose 3}+4\times5^8\times{8\choose 4}$
- $5^9\times {8\choose 5}+4\times5^8\times{8\choose 2}$
- $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$.
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$$