Let $r\_3(n) = \left|\{(a,b,c)\in {\mathbb Z}^3 :\, a^2+b^2+c^2=n \}\right|$. I am looking for the maximum asymptotic size of $r\_3(n)$. That is, the maximum number of representations that a number can have as a sum of three squares.


Gauss proved that $r\_3(n) = \frac{A\sqrt{n}}{\pi}\sum\_{m-1}^\infty\left(\frac{-n}{m}\right) \frac{1}{m}$ (where $\left(\frac{a}{b}\right)$ is the Jacobi-Legendre symbol). Another similar-looking formula can be found, for example, in the bottom of the first page of [this paper](http://www.fq.math.ca/Scanned/31-2/bhargava.pdf)


A simple and non-constructive argument shows that there are infinitely many $n$'s for which $r\_3(n) \ge c\sqrt{n}$ (for some constant $c$). Moreover, in an [old paper of Erdős](http://www.renyi.hu/~p_erdos/1960-08.pdf) he mentions that $r\_3(n) \ge c\sqrt{n}\log \log n$ can also be obtained. Unfortunately, Erdős does not provide any details and only states "By deep number theoretic results".


More specifically, my questions are (1) how can one obtain Erdős' bound? (2) What $n$'s achieve the above bounds? (3) Can one use the above formula for $r\_3(n)$ to show this?


Many thanks,
Adam



Many representations as a sum of three squares
The formula for $r\_3(n)$ essentially connects this with a class number of an imaginary quadratic field, or (apart from the $\sqrt{n}$ scaling) with the value of an $L$-function at $1$. So your question may be reformulated as asking how large can $L(1,\chi\_{d})$ be as $d$ runs over negative fundamental discriminants ($d$ is essentially $-n$). The distribution of these values has been extensively investigated (see for example [Granville and Soundararajan](http://arxiv.org/abs/math/0206031) where you'll find more references. To create large values of $L(1,\chi\_d)$ you should find a $d$ with $\chi\_d(p)=1$ for all small primes $p$ up to some point $y$. One can do this with $d$ of size about $\exp(y)$. Then for most such $d$ one will have
$$ 
L(1,\chi\_d) \approx \prod\_{p\le y} \Big(1-\frac{\chi\_d(p)}{p} \Big)^{-1} \asymp \log \log |d|
$$ 
by Mertens. Arguments of this type go back to Littlewood and Chowla (see the linked paper for references). 


