Given two natural numbers $n\geq 1$ and $b\geq 2$, denote by $S\_b(n)$ the sum of the digit of $n$ in its representation in base $b$. Clearly $S\_b(n)$ varies from 1 (when $n$ is a power of $b$) to $(b-1)\lfloor\ln{n}/\ln{b}\rfloor$ (when $n=b^k-1$ for some integer $k$). However, for a fixed $n$, the value of $S\_b(n)$ for a generic base $b$ should be of order $(b-1)/2\cdot\ln{n}/\ln{b}$. 


This lead to consider the average of $S\_b(n)$ for $b\leq n$


$$S(n):=\sum\_{b\leq n}S\_b(n)$$
or (maybe better) the wieghted average
$$S\_w(n):=\sum\_{b\leq n}\frac{S\_b(n)}{b}$$


There exists some asymptotics or non trivial bounds for $S(n)$ and $S\_w(n)$?



Average digit sum in different bases
Numerics suggest that $S(n) \sim Cn^2$ for some constant $C$ between $0.175$ and $0.18$.


Note that the bases $\frac n2<b\le n$ are easy to calculate: we get a sequence of two-digit numbers of the form $1x$, where $x$ runs from $\frac n2$ or so to $0$ (covering all integers in between). The sum of all these digits is asymptotic to $\frac12(\frac n2)^2$.


In the next range $\frac n3<b\le \frac n2$, we get a sequence of two-digit numbers of the form $2x$, where $x$ hits every other integer between about $\frac n3$ and $0$. The sum of all these digits is asymptotic to $\frac22(\frac n6)^2$.


Continuing to look at these ranges, we get a sequence of contributions of the form $\frac k2(\frac n{k(k+1)})^2$ from the bases $\frac n{k+1}<b\le\frac nk$ (at least until $k$ is about $\sqrt n$ or so). And one can calculate that
$$
\sum\_{k=1}^\infty \frac k2\bigg(\frac 1{k(k+1)}\bigg)^2 = 1-\frac{\pi^2}{12} = 0.17753...
$$


So I'm guessing that one can prove in this way that $S(n) \sim (1-\frac{\pi^2}{12})n^2$.


(Numerically $S\_w(n)$ seems to have size $n$, perhaps asymptotic to $Dn$ with some constant $D$ between $0.43$ and $0.44$. The similar heuristic doesn't give such a formula, however, because the large bases don't dominate the sum to the same extent as for $S(n)$.)


