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.

A214252 Sum of the eight nearest neighbors of n in a right triangular type-3 spiral with positive integers.

This page as a plain text file.
%I A214252 #16 May 11 2025 22:58:52
%S A214252 62,88,63,89,76,102,170,127,126,152,223,159,140,139,159,221,175,171,
%T A214252 179,202,249,353,274,252,254,262,279,323,430,330,293,283,291,299,307,
%U A214252 336,425,352,339,347,355,363,371,403,468,608,493,453,446,454,462,470,478,504
%N A214252 Sum of the eight nearest neighbors of n in a right triangular type-3 spiral with positive integers.
%C A214252 Right triangular type-1 spiral (A214230): implements the sequence Up, Right-down, Left.
%C A214252 Right triangular type-2 spiral (A214251): Left, Up, Right-down.
%C A214252 Right triangular type-3 spiral: Right-down, Left, Up.
%e A214252 Right triangular type-3 spiral begins:
%e A214252 78
%e A214252 77  46
%e A214252 76  45  47
%e A214252 75  44  22  48
%e A214252 74  43  21  23  49
%e A214252 73  42  20   7  24  50
%e A214252 72  41  19   6   8  25  51
%e A214252 71  40  18   5   1   9  26  52
%e A214252 70  39  17   4   3   2  10  27  53
%e A214252 69  38  16  15  14  13  12  11  28  54
%e A214252 68  37  36  35  34  33  32  31  30  29  55
%e A214252 67  66  65  64  63  62  61  60  59  58  57  56
%e A214252 The eight nearest neighbors of 5 are 1, 3, 4, 17, 18, 19, 6, 8. Their sum is a(5)=76.
%o A214252 (Python)
%o A214252 SIZE=28  # must be even
%o A214252 grid = [0] * (SIZE*SIZE)
%o A214252 saveX = [0]* (SIZE*SIZE)
%o A214252 saveY = [0]* (SIZE*SIZE)
%o A214252 saveX[1] = saveY[1] = posX = posY = SIZE//2
%o A214252 grid[posY*SIZE+posX]=1
%o A214252 n = 2
%o A214252 def walk(stepX, stepY, chkX, chkY):
%o A214252   global posX, posY, n
%o A214252   while 1:
%o A214252     posX+=stepX
%o A214252     posY+=stepY
%o A214252     grid[posY*SIZE+posX]=n
%o A214252     saveX[n]=posX
%o A214252     saveY[n]=posY
%o A214252     n+=1
%o A214252     if posY==0 or grid[(posY+chkY)*SIZE+posX+chkX]==0:
%o A214252         return
%o A214252 while posY!=0:
%o A214252     walk( 1, 1, -1,  0)    # right-down
%o A214252     walk(-1, 0,  0, -1)    # left
%o A214252     walk(0, -1,  1,  1)    # up
%o A214252 for n in range(1, 92):
%o A214252     posX = saveX[n]
%o A214252     posY = saveY[n]
%o A214252     k = grid[(posY-1)*SIZE+posX] + grid[(posY+1)*SIZE+posX]
%o A214252     k+= grid[(posY-1)*SIZE+posX-1] + grid[(posY-1)*SIZE+posX+1]
%o A214252     k+= grid[(posY+1)*SIZE+posX-1] + grid[(posY+1)*SIZE+posX+1]
%o A214252     k+= grid[posY*SIZE+posX-1] + grid[posY*SIZE+posX+1]
%o A214252     print(k, end=' ')
%Y A214252 Cf. A214230.
%Y A214252 Cf. A214251.
%K A214252 nonn,easy
%O A214252 1,1
%A A214252 _Alex Ratushnyak_, Jul 08 2012