2 deleted 11 characters in body

There is one answer to your question that is classical, discovered by Dirichlet. The number of proper representations of $n$ as a sum of three squares can be expressed as a sum of Jacobi symbols, for example $$r_3'(n) = 24\sum_{m \leq n/4}\left(\frac{m}{n}\right)$$ if $n \equiv 1{\;}(4)$. Here $r_3'(n)$ denotes the number of proper representations, where $x,y,z$ in $x^2 + y^2 + z^2 = n$ has no common factor. If $n$ is squarefree then $r_3(n) = r_3'(n)$, otherwise $r_3(n)$ is given by a sum $$r_3(n) = \sum_{d^2|n}r_3'(n/d^2)$$ The above formula strongly suggests that there is no simple closed form expression for $r_3(n)$.

Whether this answer really qualifies as nice in your sense I am not certainis uncertain. It is necessary to separate into cases. The formula looks slightly different when $n \equiv 3{\;}(4)$. How it looks when $n$ is even I do not know.

I should mention that Gauss had expressed the number of proper representations of $n$ as a sum of three squares in terms of class numbers of binary quadratic forms. Dirichlet obtained his formulas for $r_3'(n)$ by applying his class number formula.

1

There is one answer to your question that is classical, discovered by Dirichlet. The number of proper representations of $n$ as a sum of three squares can be expressed as a sum of Jacobi symbols, for example $$r_3'(n) = 24\sum_{m \leq n/4}\left(\frac{m}{n}\right)$$ if $n \equiv 1{\;}(4)$. Here $r_3'(n)$ denotes the number of proper representations, where $x,y,z$ in $x^2 + y^2 + z^2 = n$ has no common factor. If $n$ is squarefree then $r_3(n) = r_3'(n)$, otherwise $r_3(n)$ is given by a sum $$r_3(n) = \sum_{d^2|n}r_3'(n/d^2)$$ The above formula strongly suggests that there is no simple closed form expression for $r_3(n)$.

Whether this answer qualifies as nice in your sense I am not certain. It is necessary to separate into cases. The formula looks slightly different when $n \equiv 3{\;}(4)$. How it looks when $n$ is even I do not know.

I should mention that Gauss had expressed the number of proper representations of $n$ as a sum of three squares in terms of class numbers of binary quadratic forms. Dirichlet obtained his formulas for $r_3'(n)$ by applying his class number formula.