Pick an integer $b \ge 2$, and for $n \in \mathbf N$ let $s_b(n)$ denote the sum of the base-$b$ digits of $n$. It is a nice exercise to prove that $$s_b(n) = (b-1) \sum_{i=1}^\infty \left\{\frac{n}{b^i}\right\}.$$ In particular, this follows at once from $$s_b(n) = n - (b-1) \sum_{i=1}^\infty \left\lfloor \frac{n}{b^i}\right\rfloor,$$ and I seem to remember that the latter is due to Legendre, but I don't remember where I first read it and cannot find any reference, which is why I'm writing. So, thank you in advance for any help.
Edit. A 1967 note by Trollope on the AMM (click) mentions the second of the above identities; the author refers the reader to p. 12 in the 1955 edition of Legendre's Théorie des Nombres (which is consistent with the answer of Konstantinos Gaitanas, below). Unluckily, I have only a copy of a previous edition of the book (namely, the 1830 edition), where Legendre seems to consider only the case where $b$ is prime. Thus, I'm a little bit puzzled, since Trollope doesn't assume this condition in his note. Is there anybody with access to the 1955 edition?