OFFSET
1,1
EXAMPLE
Hexagonal grid with integers up to 85:
29<---28<---27<---26<-7,25<=6,24<==5/23
/ / \\
30 8 4/22
/ / \\
31,53<-52<---51<---50<--9,49<--48<---47 3,21
/ \ / \ / \
54 32 10 1,46--->2 20
/ \ / \ \
55,79<--78<-33,77<--76<-11,75<--74<---73 45 19
// \ \ \ \ /
56,80 34 12 72 44 18
// \ \ \ / \ /
57,81 35 13--->14->15,71-->16-->17,43
// \ / /
58,82 36 70 42
// \ / /
59,83 37--->38->39,69-->40--->41
\\ /
60,84 68
\\ /
61,85--->62--->63--->64--->65--->66--->67
Prime number (p), square of the distance (s) from p to origin, and index (n) in the sequence for p up to 71 are:
p: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71
s: 1 3 7 9 13 13 9 7 7 37 43 31 19 9 1 43 109 109 43 7
n: 1 2 3 4 5 -- -- -- -- 6 7 -- -- -- -- -- 8 -- -- --
PROG
(Python)
from sympy import isprime
dx = [2, 1, -1, -2, -1, 1]; dy = [0, 1, 1, 0, -1, -1]
x = 0; y = 0; rec = 0; d = 0
for n in range(2, 10001):
if isprime(n-1) == 1: d += 1; d %= 6
x += dx[d]; y += dy[d]; s = x*x + 3*y*y
if isprime(n) == 1 and s > rec: print(n); rec = s
CROSSREFS
KEYWORD
nonn
AUTHOR
Ya-Ping Lu, Apr 15 2021
STATUS
approved