<s>[INST] Number of nine digits numbers whose sum of the digits is even I am reading Mathematical Circle. Problem $48$ in chapter two says that 

How many nine-digit numbers have an even sum of their digits?

I am trying in this way, that we can divide the problem in four cases. 


*

*$1$ even digit and $8$ odd digits

*$3$ even digits and $6$ odd digits

*$5$ even digits and $4$ odd digits

*$7$ even digits and $2$ odd digits


For the first case we get $4 \cdot 5^8 +5\cdot 5^7 \cdot 5$ number of solution. Because if the even digit is placed in first place (left to right) then we get $4\cdot 5^8$ ways to write the number and if an odd digit is placed in first place then we get $5\cdot 5^7 \cdot 5$ ways to write the number. Similarly for the second case we get $4\cdot 5^8+5^9$ , for the third case we get $4\cdot 5^8+5^9$ and for the fourth case we get $4\cdot 5^8+5^9$ ways to write the number. So total number is $ 4 \cdot (4\cdot 5^8+5^9)$. 
The answer is different. So Where I have made a mistake?
Thanks.
 [/INST] Let $A$ be the set of nine digit numbers. Its size is $|A|=9\cdot10^8$: we're free to choose eight digits among all ten digits, but the most significant digit can't be zero.
Now consider the following map $f\colon A\to A$:
$$
f(x)=\begin{cases}
x-9 & x\equiv 9\pmod{10} \\[4px]
x+1 & x\not\equiv9\pmod{10}
\end{cases}
$$
The map is bijective. If $A_0$ and $A_1$ denote the subsets of $A$ consisting of numbers with even or, respectively, odd digit sum, we can see that $f$ induces bijective maps $f_{01}\colon A_0\to A_1$ and $f_{10}\colon A_1\to A_0$.
Therefore $|A_0|=|A|/2=45\cdot10^7$.
</s>