I have asked this question exactly here. The question is as follows:
I am interested deeply in the following problem:
Let $f$ be a (fixed) positive definite quadratic form; and let $n$ be an arbitrary natural number; then find a closed formula for the number of solutions to the equation $f=n$.
For special case $P_{-4}(x,y)=x^2+y^2$, here gives a closed formula for number of solutions.
Also, you can find another formula for the special cases $P_{-20}(x,y)=x^2+5y^2$ and $P_{-28}(x,y)=x^2+7y^2$ there.You can finde a close formula here for $P_{-8}(x,y)=x^2+2y^2$, here.
You can finde a close formula here for $P_{-3}(x,y)=x^2+xy+y^2$, here. Also, you can find the answer for (only finitely many) other forms there, maybe this helps too.
You can finde a close formula here for $f(x,y,z,w)=x^2+y^2+z^2+w^2$, here.
By a more Intelligently search through the web; you can find similar formulas for the only finite limited number of positive definite quadratic forms.
[I think there exists such an explicit formula at most for $10000$ quadratic forms. Am I right?]
As I have mentioned (I am not sure of it!) only for a finite number of quadratic forms we have such an explicit, closed, nice formula; and this way goes in the dead-end for arbitrary quadratic forms.
So Dirichlet tries to find the (weighted) sum of such representations by binary quadratic forms of the same discriminant.
That formula works very nice for our purpose if the genera contain exactly one form. In the Dirichlet formula, each binary quadratic forms appears by weight one in the (weighted) sum.
More precisely let $f_1, f_2, ..., f_h=f_{h(D)}$ be a complete set of representatives for reduced binary quadratic forms of discriminant $D < 0$;
then for every $n \in \mathbb{N}$, with $\gcd(n,D)=1$ we have:
$$ \sum_{i=1}^{h(D)} N(f_i,n) = \omega (D) \sum_{d \mid n} \left( \dfrac{D}{d}\right) ; $$
where $\omega (-3) =6$ and $\omega (-4) =4$ and for every other (possible) value of $D<0$ we have $\omega (D) =2$. Also by $N(f,n)$; we meant number of integral representations of $n$ by $f$; i.e. :
$$ N(f,n) := N\big(f(x,y),n\big) = \# \{(x,y) \in \mathbb{Z}^2 : f(x,y)=n \} . $$
I have heard that there is a generalization of Dirichlet's theorem; for quadratic forms in more variables, due to Siegel. I have searched through the web; but I have found only this link : Smith–Minkowski–Siegel mass formula ; also, I confess that I can't understand the whole of this wiki-article.
Could anyone introduce me a simple reference in English; for Siegel mass formula?
Also you can find better informations here, and may be here & here.