I will begin by saying that $k=3$ might be a very specific case and this question is useless. Even if that is the case, I would like to know...


The sum of squares function $r\_k(n)$ is very famous. It counts the number of ways $n$ can be written as a sum of $k$ squares. In the case of $k=3$, when $n$ is squarefree and not $7\mod{8}$, $r\_k(n)$ is related to the class number of $\mathbb{Q}(\sqrt{-n})$. In the next (at least) two odd cases the function is still related to arithmetic constants of quadratic fields. C.f. "On the Representation of a Number as the Sum of any Number of Squares, and in Particular of five or seven", Hardy, 1918.


### Question


Are the numbers $r\_k(n)$ known to be related to special groups, like when $k=3$?


### Smaller Question


Is there a book with an in-depth account of these numbers and their arithmetic significance? (more than expressing them as coefficients of a modular form and proving bounds and (lots of) relations...)



Groups related to sum of squares function?
In my view, it depends a little what you mean by "related," but I don't see at first glance any natural group whose order is r\_k(n) for any k other than 3. Loosely speaking, representations of a form of rank m by the genus of a form of rank n are related to the set of double cosets


H(Q) \ H(A\_f) / H(Zhat)


where H is a form of SO\_{n-m} (this can be found e.g. in my paper with Venkatesh "Local-global principles..." but is certainly known to others). When H is abelian (i.e. when n-m = 2) this is naturally a group, otherwise not. 


