Find all expressions of a prime as a sum of four squares
Does anyone know an efficient algorithm to compute all solutions of $$ x^2 + y^2 + z^2 + w^2 = p $$ where $x, y, z, w \in \mathbb{Z}$ and $p \in \mathbb{P}$?
By efficient I mean linear on the number of solutions: $8(p + 1)$.
$\endgroup$ 31 Answer
$\begingroup$Your question is similiar to langrage four square theorem.Michael O. Rabin and Jeffrey Shallit have found randomized polynomial-time algorithms for computing a representation $ n = x^2 + y^2 + z^2 + w^2$ for a given integer n, in expected running time $O((logn)^2).$
$\endgroup$ 2