[Math] Number of 5-digit numbers such that the sum of their digits is even

combinatorics

I found the same question on this site and many others…where everywhere the answer $45000$ is written …while I have no problem with this but I am having problems with the logical answer…as everywhere it is written since total numbers is $90000$ so half of the numbers satisfy the above condition(but why??it is not explained anywhere as to how we can say that half the numbers satisfy this condition)…I know that half the numbers are even and half the numbers are odd…but that is not what we are asked here…we need to find numbers whose sum of digits is even …and not numbers who are just even… I think these conditions are very different but it is used evrwhere…can someone please clarify..this.??..as to how we can say..half the numbers have their sum of digits as even??
i don't think this question is entirely a duplicate but if it please let me know…where I can get the explanation of what I am asking..

Best Answer

To expand on the wonderful insight of Alain Remillard in the comments, let's consider the set of all $5$ digit numbers. Now, you can partition this set into $9 \times 10^3$ subsets (we exclude a leading $0$ as a possibility) each of which contains all numbers with a common prefix of $4$ numbers. For example, one of the partitions, for the prefix $2346$ would be:

$$\{23460, 23461, 23462, 23463, \dots, 23469\}$$

Note that each partition contains exactly $10$ elements, with the last digit numbered $0-9$. Now, to prove that exactly half the numbers in the entire set have even digit sums, all we have to do is to prove that half the numbers in each of these partitions has an even digit sum. So we've reduced the problem to something much simpler! I hope you can see why.

Now, to show that in any partition there are exactly $5$ elements with an even digit sum, consider the first element in the set e.g. in the above it would be $23460$. The sum of its digits is either even or odd. If it's even, then the next number will be odd, because you're just adding $1$ to it, and vice versa (the example is 15, which is odd). Then the sums go: even, odd, even, odd, even, odd etc. Or else they go: odd, even, odd, even etc. In either case, there are exactly $10$ elements, $5$ even, and $5$ odd. And we are done.


Update: As the OP cleverly points out in the comments below, the choice to fix the first four digits is indeed arbitrary. The first digit must be fixed, because there are only $9$ possibilities for this, but after this any three of the remaining four digits can be fixed. The remaining digit will then have ten possibilities, and the proof will proceed just as above.