login
A215470
Prime intersections in a square spiral with positive integers: primes p such that there are four primes among eight nearest neighbors of p.
1
71, 353, 701, 1151, 1451, 3347, 4691, 13463, 21017, 27947, 34337, 42017, 52253, 57191, 79907, 80831, 81611, 121469, 144497, 159737, 161141, 256301, 265547, 284231, 285707, 312161, 334511, 346559, 348617, 382601, 392069, 422867, 440303, 502013, 541061, 545873, 593207
OFFSET
1,1
COMMENTS
Conjecture: the sequence is infinite. - Alex Ratushnyak, Sep 19 2012
EXAMPLE
The spiral begins:
.
121 82--83--84--85--86--87--88--89--90--91
| | |
120 81 50--51--52--53--54--55--56--57 92
| | | | |
119 80 49 26--27--28--29--30--31 58 93
| | | | | | |
118 79 48 25 10--11--12--13 32 59 94
| | | | | | | | |
117 78 47 24 9 2---3 14 33 60 95
| | | | | | | | | | |
116 77 46 23 8 1 4 15 34 61 96
| | | | | | | | | |
115 76 45 22 7---6---5 16 35 62 97
| | | | | | | |
114 75 44 21--20--19--18--17 36 63 98
| | | | | |
113 74 43--42--41--40--39--38--37 64 99
| | | |
112 73--72--71--70--69--68--67--66--65 100
| |
111-110-109-108-107-106-105-104-103-102-101
.
Among eight nearest neighbors of 71 four are primes: 41, 43, 107, 109.
PROG
(Python)
SIZE = 3335 # must be odd
TOP = SIZE*SIZE
prime = [1]*TOP
prime[1]=0
for i in range(4, TOP, 2):
prime[i]=0
for i in range(3, TOP, 2):
if prime[i]==1:
for j in range(i*3, TOP, i*2):
prime[j]=0
grid = [0] * TOP
posX = posY = SIZE//2
grid[posY*SIZE+posX] = 1
n = 2
saveX = [0]* (TOP+1)
saveY = [0]* (TOP+1)
saveX[1]=posX
saveY[1]=posY
def walk(stepX, stepY, chkX, chkY):
global posX, posY, n
while 1:
posX+=stepX
posY+=stepY
grid[posY*SIZE+posX]=n
saveX[n]=posX
saveY[n]=posY
n+=1
if posX*posY==0 or grid[(posY+chkY)*SIZE+posX+chkX]==0:
return
while 1:
walk(0, -1, 1, 0) # up
if posX*posY==0:
break
walk(1, 0, 0, 1) # right
walk(0, 1, -1, 0) # down
walk(-1, 0, 0, -1) # left
for s in range(1, n):
if prime[s]:
posX = saveX[s]
posY = saveY[s]
a, b=(grid[(posY-1)*SIZE+posX-1]) , (grid[(posY-1)*SIZE+posX+1])
c, d=(grid[(posY+1)*SIZE+posX-1]) , (grid[(posY+1)*SIZE+posX+1])
if a*b==0 or c*d==0:
break
if prime[a]+prime[b]+prime[c]+prime[d]==4:
print s,
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Aug 11 2012
STATUS
approved