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.

A215471 Numbers k such that in a rotated-square spiral with positive integers (A215468) among k's eight nearest neighbors five or more are primes.

This page as a plain text file.
%I A215471 #9 Aug 05 2025 17:43:13
%S A215471 8,30,138,658,2620,3010,3168,3372,3462,8628,11940,17682,24918,27918,
%T A215471 32560,39228,39790,40128,43608,48532,53268,55372,56040,56712,73362,
%U A215471 85200,85888,90646,96052,101748,102652,104382,112068,113932,115330,119298,128518,129288,131500
%N A215471 Numbers k such that in a rotated-square spiral with positive integers (A215468) among k's eight nearest neighbors five or more are primes.
%H A215471 David Radcliffe, <a href="/A215471/b215471.txt">Table of n, a(n) for n = 1..10391</a>
%e A215471 Spiral begins:
%e A215471                             113
%e A215471                         112  85  86
%e A215471                     111  84  61  62  87
%e A215471                 110  83  60  41  42  63  88
%e A215471             109  82  59  40  25  26  43  64  89
%e A215471         108  81  58  39  24  13  14  27  44  65  90
%e A215471     107  80  57  38  23  12   5   6  15  28  45  66  91
%e A215471 106  79  56  37  22  11   4   1   2   7  16  29  46  67  92
%e A215471     105  78  55  36  21  10   3   8  17  30  47  68  93
%e A215471         104  77  54  35  20   9  18  31  48  69  94
%e A215471             103  76  53  34  19  32  49  70  95
%e A215471                 102  75  52  33  50  71  96
%e A215471                     101  74  51  72  97
%e A215471                         100  73  98
%e A215471                              99
%e A215471 Among eight nearest neighbors of 30 five are primes: 7, 17, 31, 29, 47.
%o A215471 (Python)
%o A215471 SIZE = 3335  # must be odd
%o A215471 TOP = SIZE*SIZE
%o A215471 t = TOP//2
%o A215471 prime = [1]*t
%o A215471 prime[1]=0
%o A215471 for i in range(4,t,2):
%o A215471     prime[i]=0
%o A215471 for i in range(3,t,2):
%o A215471     if prime[i]==1:
%o A215471         for j in range(i*3,t,i*2):
%o A215471             prime[j]=0
%o A215471 grid = [0] * TOP
%o A215471 posX = posY = SIZE//2
%o A215471 saveX = [0]* (t+1)
%o A215471 saveY = [0]* (t+1)
%o A215471 grid[posY*SIZE+posX] = 1
%o A215471 saveX[1]=posX
%o A215471 saveY[1]=posY
%o A215471 posX += 1
%o A215471 grid[posY*SIZE+posX] = 2
%o A215471 saveX[2]=posX
%o A215471 saveY[2]=posY
%o A215471 n = 3
%o A215471 def walk(stepX, stepY, chkX, chkY):
%o A215471   global posX, posY, n
%o A215471   while 1:
%o A215471     posX+=stepX
%o A215471     posY+=stepY
%o A215471     grid[posY*SIZE+posX]=n
%o A215471     saveX[n]=posX
%o A215471     saveY[n]=posY
%o A215471     n+=1
%o A215471     if grid[(posY+chkY)*SIZE+posX+chkX]==0:
%o A215471         return
%o A215471 while posX!=SIZE-1:
%o A215471     walk(-1,  1, -1, -1)    # down-left
%o A215471     walk(-1, -1,  1, -1)    # up-left
%o A215471     walk( 1, -1,  1,  0)    # up-right
%o A215471     walk( 1,  0,  1,  1)    # right
%o A215471     walk( 1,  1, -1,  1)    # down-right
%o A215471 for s in range(1, n):
%o A215471     posX = saveX[s]
%o A215471     posY = saveY[s]
%o A215471     a,b=(grid[(posY-1)*SIZE+posX-1]) , (grid[(posY-1)*SIZE+posX+1])
%o A215471     c,d=(grid[(posY+1)*SIZE+posX-1]) , (grid[(posY+1)*SIZE+posX+1])
%o A215471     e,f=(grid[(posY-1)*SIZE+posX  ]) , (grid[(posY+1)*SIZE+posX  ])
%o A215471     g,h=(grid[ posY   *SIZE+posX-1]) , (grid[ posY   *SIZE+posX+1])
%o A215471     if a*b==0 or c*d==0 or e*f==0 or g*h==0:
%o A215471         break
%o A215471     z = prime[a]+prime[b]+prime[c]+prime[d]
%o A215471     if z+prime[e]+prime[f]+prime[g]+prime[h] >= 5:
%o A215471         print(s, end=' ')
%o A215471 (Python) # See A215468 for the definition of spiral().
%o A215471 from sympy import isprime
%o A215471 def neighbors(n):
%o A215471     x = A010751(n-1)
%o A215471     y = A305258(n-1)
%o A215471     return [spiral(x+i, y+j) for i in (-1, 0, 1) for j in (-1, 0, 1) if (i, j) != (0, 0)]
%o A215471 def is_A215471(n): return sum(map(isprime, neighbors(n))) >= 5 # _David Radcliffe_, Aug 05 2025
%Y A215471 Cf. A215468, A215470.
%Y A215471 Cf. A039625.
%K A215471 nonn
%O A215471 1,1
%A A215471 _Alex Ratushnyak_, Aug 11 2012