# Number of 5-digit numbers such that the sum of their digits is even

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..

• Hint: a sum of numbers is even if and only if there are an even number of odd numbers in the sum. – Colm Bhandal Nov 25 '15 at 18:23
• An other way of seeing it, the last number decide if the sum is odd or even. If the sum of the 4 first numbers is even, then the last number need to be even. If the sum of the 4 first numbers is odd, then the last number need to be odd. – Alain Remillard Nov 25 '15 at 18:26
• @Colm That is a very complicated use of even and odd term...!!..can you please expand this comment just a little bit...so that I can at least get a hint... – Freelancer Nov 25 '15 at 18:26
• @Freelancer- actually I think Alain Remillard's suggestion is the more elegant of the two. Can you see how this leads to the result? How many possibilities are there for that last digit? And how many of them result in an even number, how many in an odd number? – Colm Bhandal Nov 25 '15 at 18:28

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.

• Well ..you fixed the first 3-digits...and then showed that for the last digit half numbers will be positive and half will be negative...let us say I want to think in another way and I fix the last three digits(say for example $X234$ and then show that half of the numbers so formed will be having sum as even and half will be having sum as odd...is that correct also?? ...can I do this... – Freelancer Nov 25 '15 at 19:03
• @Freelancer- that is a very clever insight. Nicely though out :):) Yes you can indeed fix any three digits and the first digit and the above method will work. I will update accordingly. – Colm Bhandal Nov 26 '15 at 12:00

• even + even = even
• even + odd = odd
• odd + odd = even

Using this we can show the even-ness of the sum of digits. Take $234582$. We have

$$E + O + E + O + E + E \\= (E + O) + (E + O) + (E + E) \\= O + O + E \\= (O+O) + E \\= E + E \\= E.$$

So, for a five-digit number, what numbers of odd digits can we have to make the sum even?

Next, let's count the number of five-digit numbers that have three odd digits. (Is the sum of digits of these numbers even or odd?)

There are $125$ three-digit odd numbers. (Why?) There are $_5C_3 = 10$ combinations of places we can put the digits in order within the five-digit number. Then, there are $25$ two-digit even numbers. So the number of five digit numbers with three odd digits is $125 \cdot 10 \cdot 25 = 31250.$ (I'm assuming leading zeroes are valid (like $00123$)).

To solve the problem, then, you'll need to determine what numbers of odd digits will give you an even sum, and then count each of those cases.