Consider the decimal (base 10) expansion of \(a\text{:}\)
\begin{equation*}
a=\sum_{i=0}^n a_i 10^i
\end{equation*}
Then the base 10 representation of \(a\) is \(a=(a_n \dots a_1 a_0)\text{.}\) We take both sides modulo 9 and obtain.
\begin{align*}
a \bmod 9 \amp = \left(\sum_{i=0}^n a_i 10^i\right) \bmod 9 \\
\amp = \left(\sum_{i=0}^n a_i (10\bmod 9)^i\right) \bmod 9
\end{align*}
Because \(10\bmod 9=1\) we have
\begin{align*}
a \bmod 9
\amp= \left(\sum_{i=0}^n a_i 1^i\right)\bmod 9\\\\
\amp= \left(\sum_{i=0}^n a_i\right)\bmod 9.
\end{align*}
Which means that \(\displaystyle a\equiv \left(\sum_{i=0}^n a_i\right)\pmod{9}\text{.}\)