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](http://www.jstor.org/discover/10.2307/2314259?uid=3738016&uid=2129&uid=2&uid=70&uid=4&sid=21103897887933)) 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](https://mathoverflow.net/a/161984)). 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?



Looking for a reference to a classical formula for the sum of the base-$b$ digits of an integer
Sorry for answering my own question, but it turns out that the second identity in the OP is explicitly stated and proved in: L. D. Yarbrough and S. Rabinowitz, *Solution to Problem E1926*, Amer. Math. Monthly **75** (Mar., 1968), No. 3, 296.


