cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A215470 Prime intersections in a square spiral with positive integers: primes p such that there are four primes among eight nearest neighbors of p.

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