I was intrigued by this result in Journal of Number Theory from 2013. Let $ n = 2^{\lambda_2}\prod p^{\lambda_p}$ . Theorem The number of $ (x,y,z) \in \mathbb{Z}^3$ such that $ n^ 2 = x^2 + y^2 + 2z^2$ is given by $ $ b(\lambda_2) \prod_p \left[ \frac{p^{\lambda_p+1}-1}{p-1} – \left( \frac{-2}{p}\right)\frac{p^{\lambda_p}-1}{p-1} \right]$ $ and theRead more