Digit sum formula $n - 9 \sum_{i\ge1} \left \lfloor \frac{n}{10^i} \right \rfloor$ Let $S(n)$ be the sum of digits of n
Prove that $S(n) = n  -  9 \sum_{i\ge 1} \left \lfloor \frac{n}{10^i} \right \rfloor$ for all natural numbers n
I started with induction which works easily if $10$ doesn't divide $n+1$, because then $S(n+1)$ is just $S(n) + 1$.
However, if $10|(n+1)$ then $S(n+1)$ could be anything. Moreover, I have no idea how to use that fact.
If I write e.g. $n = 10k + 9$ then $\sum_{i\ge1} \left \lfloor \frac{10k+10}{10^i} \right \rfloor$ = $\sum_{i\ge1} \left \lfloor \frac{k+1}{10^{i-1}} \right \rfloor$  and I don't know how to proceed

Using strong induction, assume for all $n = 1,2, \ldots, k$, the sum of digits formula holds:
$$S(n) = n - 9\sum_{i\ge 1} \left\lfloor\frac n{10^i}\right\rfloor$$
The induction step would be to prove that $S(k+1)$ follows the same formula.
For the cases that $10\mid (k+1)$, let $k+1 = 10q$, (and so $1\le q \le k$)
$$\begin{align*}
S(k+1) &= S\left(\frac{k+1}{10}\right)\\
&= S(q)\\
&= q - 9\sum_{i\ge 1} \left\lfloor\frac q{10^i}\right\rfloor\\
&= \frac{k+1}{10} - 9 \sum_{i\ge 1} \left\lfloor\frac {(k+1)/10}{10^i}\right\rfloor\\
&= 10\cdot\frac{k+1}{10}-9\cdot\frac{k+1}{10} - 9 \sum_{j\ge 2} \left\lfloor\frac {k+1}{10^j}\right\rfloor && (j=i+1)\\
&= (k+1) - 9 \sum_{j\ge 1} \left\lfloor\frac {k+1}{10^j}\right\rfloor\\
&= RHS
\end{align*}$$
For the other cases that $10\not\mid(k+1)$, OP already mentioned in the question that $S(k+1) = S(k)+1$.

It is possible to merge the two cases with a slight change, by also proving the base case $n=0$ and including it into the assumption.
For the $n=k+1$ case, let $k+1 = 10q + r$, where $q = \left\lfloor \dfrac{k+1}{10}\right\rfloor$ and $r=(k+1)\bmod 10$.
$$\begin{align*}
S(k+1) &= S(q) + r\\
&= q - 9\sum_{i\ge 1} \left\lfloor\frac q{10^i}\right\rfloor + r\\
&= q - 9\sum_{i\ge 1} \left\lfloor\frac {10q/10}{10^i}\right\rfloor + r\\
&= 10q - 9\cdot \frac{10q}{10} - 9\sum_{j\ge 2} \left\lfloor\frac {10q}{10^j}\right\rfloor + r&&(j=i+1)\\
&= 10q - 9\sum_{j\ge 1} \left\lfloor\frac {10q}{10^j}\right\rfloor + r\\
&= 10q+r - 9\sum_{j\ge 1} \left\lfloor\frac {10q}{10^j} + \frac{r}{10^j}\right\rfloor\\
&= (k+1) - 9\sum_{j\ge 1} \left\lfloor\frac {k+1}{10^j}\right\rfloor\\
&= RHS
\end{align*}$$
