TITLE: Primes that are the sum of three squares
QUESTION [9 upvotes]: This is in some sense an extension of the earlier MO question, "Gaussian prime spirals."
Gaussian primes in the complex plane, $a+b i$, require $a^2 +b^2$ prime off the axes.
The generalization to quaternions leads to Hurwitz primes $a + b i + c j + d k$, which
require $a^2 + b^2 + c^2 + d^2$ prime (here I am ignoring the Hurwitz integers whose
components are in $\mathbb{Z}+\frac{1}{2}$).
So this suggests exploring points in $\mathbb{Z}^3$ with $a^2+b^2+c^2$ prime.
(I realize this ignores the nice algebraic properties of complex numbers and quaternions.)
The Gaussian prime spirals were created by walking along a lattice direction and turning 
left at Gaussian primes.  The generalization is to start at a point $p \in \mathbb{Z}^3$, walk
along a lattice direction until a point $(a,b,c)$ is hit with $a^2 +b^2 + c^2$ prime, and then 
turn.  It makes sense to iterate through the six lattice directions,
$(+x,+y,+z,-x,-y,-z)$, in that order.
The result seems again to be a closed cycle.
Here is one example, with $p=(30,40,10)$ (marked in red), 
which cycles after encountering 739 "primes" (marked in yellow):
         

It appears that whether or not every Gaussian prime spiral cycles runs up against
long-unsolved problems.
What is the situation with these 3D "prime" spirals?
Is there much known about the density and distribution of primes that are
are sum of three squares?
Are there theorems or conjectures that would either imply all spirals are closed,
or the opposite, that there should exist infinite unclosed spirals?

REPLY [9 votes]: From one direction, everything is known about the resulting primes. All primes 
$$  p \equiv 1,3,5 \pmod 8  $$ are the sum of three squares, so is $p=2,$ while no numbers
$$  n \equiv 7 \pmod 8  $$ are ever the sum of three squares.
However, your construction involves fixing two coordinates, say $x=a, y=b,$ then varying $z$ in either direction and hoping to find another prime. This is still unsure, for example if 
$a^2 + b^2 = 1,$ nobody knows for sure that there are infinitely many primes of the form $1 + z^2.$
For what it may be worth, Siegel's theorem gives an exact answer for the number of representations of a given number $n = x^2 + y^2 + z^2$ because the form is alone in its genus. I also gave a version in the style of Guass at Is there a simple way to compute the number of ways to write a positive integer as the sum of three squares?  Meanwhile, following Linnik, the main result in Duke and Schulze-Pillot (1990) is that the lattice points on the sphere are asymptotically equidistributed.  
About Guass, I had a girlfriend who had taken Latin, and expressed a desire to write a murder mystery with hero Dexter, while only in the last few pages do we find out about the evil twin Sinister.  The class had a motto, Semper Ubi Sub Ubi or Always Wear Underwear.