OFFSET
1,1
COMMENTS
The Gaussian prime spiral is described in the short note by O'Rourke and Wagon. It is not known if every iteration is a closed loop. See A222299 for the number of distinct primes on the spiral. See A222300 for the length of the spiral (which is the same as the number of numbers tested for primality, without memory).
REFERENCES
Joseph O'Rourke and Stan Wagon, Gaussian prime spirals, Mathematics Magazine, vol. 86, no. 1 (2013), p. 14.
LINKS
T. D. Noe, Table of n, a(n) for n = 1..1000
T. D. Noe, Plot beginning with 11 (similar to the cover of Mathematics Magazine, vol. 86, no. 1 (2013))
Joseph O'Rourke, MathOverflow: Gaussian prime spirals
EXAMPLE
The loop beginning with 31 is {31, 43, 43 - 8i, 37 - 8i, 37 - 2i, 45 - 2i, 45 - 8i, 43 - 8i, 43, 47, 47 - 2i, 45 - 2i, 45 + 2i, 47 + 2i, 47, 43, 43 + 8i, 45 + 8i, 45 + 2i, 37 + 2i, 37 + 8i, 43 + 8i, 43, 31, 31 + 4i, 41 + 4i, 41 - 4i, 31 - 4i, 31}. The first and last numbers are the same. So only one is counted.
MATHEMATICA
loop[n_] := Module[{p = n, direction = 1}, lst = {n}; While[While[p = p + direction; ! PrimeQ[p, GaussianIntegers -> True]]; direction = direction*(-I); AppendTo[lst, p]; ! (p == n && direction == 1)]; Length[lst]]; cp = Select[Range[1000], PrimeQ[#, GaussianIntegers -> True] &]; Table[loop[p]-1, {p, cp}]
CROSSREFS
KEYWORD
nonn
AUTHOR
T. D. Noe, Feb 25 2013
STATUS
approved