OFFSET
1,1
COMMENTS
Cells can contain more than one number.
This sequence differs from A309701, where the Manhattan distance is taken.
LINKS
Pieter Post, Table of n, a(n) for n = 1..182
EXAMPLE
Grid of the first 34 steps. 0 (second cell in sixth row) represents (0,0).
---
xx xx xx 31 30 29
xx xx xx 32 xx 28
xx xx xx 33 xx 27
xx xx xx 34 xx 26
xx 5/17 4/16 3/15 14 13/25
x 0/6/18 1 2 xx 12/24
xx 7/19 8/20 9/21 10/22 11/23
---
2 (2,0) is two steps away from the origin, 3 (2,1) is at a distance of sqrt(5). Next record distance is 11 (4,-1), at distance sqrt(17). Next is 29 (4,5), at distance sqrt(41).
MATHEMATICA
step[n_] := Switch[n, 0, {1, 0}, 1, {0, 1}, 2, {-1, 0}, 3, {0, -1}]; r = {0, 0}; q = 0; s={}; rm=0; Do[p = NextPrime[q]; r += step[Mod[n, 4]] * (p-q); r1 = Total @ (r^2); If[r1 > rm, rm = r1; AppendTo[s, p]]; q = p, {n, 0, 3000}]; s (* Amiram Eldar, Aug 15 2019 *)
PROG
(Python)
from sympy import isprime
n, g, h=[], [1, 0, -1, 0], [0, 1, 0, -1]
z=10000
ca, cb, cc=2, 0, 0
for j in range(2, z):
if isprime(j):
cc=cc+1
cd, ce=g[cc%4], h[cc%4]
ca, cb=ca+cd, cb+ce
n.append([j+1, ca, cb, ca**2+cb**2])
print(2, end=', ')
v=4
for j in n:
if j[3]>v and isprime(j[0]):
print(j[0], end=', ')
v=j[3]
(PARI) z=0; d=1; m=0; for (n=1, 3727, z+=d; if (isprime(n), d*=I; if (m<norm(z), m=norm(z); print1 (n ", ")))) \\ Rémy Sigrist, Aug 15 2019
(Python)
from sympy import isprime; from math import sqrt; x = y = d = rec = 0
for n in range(1, 3750):
dx = 1 if d == 0 else -1 if d == 2 else 0; x += dx
dy = 1 if d == 1 else -1 if d == 3 else 0; y += dy
if isprime(n):
d = (d + 1)%4; z = sqrt(x*x + y*y)
if z > rec: print(n, end = ', '); rec = z # Ya-Ping Lu, Nov 05 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Pieter Post, Aug 15 2019
STATUS
approved
