login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A214251 Sum of the eight nearest neighbors of n in a right triangular type-2 spiral with positive integers. 5
62, 64, 69, 125, 94, 111, 170, 118, 105, 116, 169, 132, 131, 151, 192, 284, 217, 201, 206, 220, 258, 353, 265, 234, 227, 235, 243, 269, 349, 285, 275, 283, 291, 299, 328, 387, 515, 412, 378, 374, 382, 390, 398, 421, 477, 608, 484, 435, 419, 427, 435 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

Right triangular type-1 spiral (A214230): implements the sequence Up, Right-down, Left.

Right triangular type-2 spiral: Left, Up, Right-down.

Right triangular type-3 spiral (A214252): Right-down, Left, Up.

LINKS

Table of n, a(n) for n=1..51.

EXAMPLE

Right triangular type-2 spiral begins:

67

66  68

65  37  69

64  36  38  70

63  35  16  39  71

62  34  15  17  40  72

61  33  14   4  18  41  73

60  32  13   3   5  19  42  74

59  31  12   2   1   6  20  43  75

58  30  11  10   9   8   7  21  44  76

57  29  28  27  26  25  24  23  22  45  77

56  55  54  53  52  51  50  49  48  47  46  78

The eight nearest neighbors of 5 are 1, 2, 3, 4, 18, 41, 19, 6. Their sum is a(5)=94.

PROG

(Python)

SIZE=29  # must be odd

grid = [0] * (SIZE*SIZE)

saveX = [0]* (SIZE*SIZE)

saveY = [0]* (SIZE*SIZE)

saveX[1] = saveY[1] = posX = posY = SIZE//2

grid[posY*SIZE+posX]=1

n = 2

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 posY==0 or grid[(posY+chkY)*SIZE+posX+chkX]==0:

        return

while 1:

    walk(-1, 0,  0, -1)    # left

    walk(0, -1,  1,  1)    # up

    if posY==0:

        break

    walk( 1, 1, -1,  0)    # right-down

for n in range(1, 92):

    posX = saveX[n]

    posY = saveY[n]

    k = grid[(posY-1)*SIZE+posX] + grid[(posY+1)*SIZE+posX]

    k+= grid[(posY-1)*SIZE+posX-1] + grid[(posY-1)*SIZE+posX+1]

    k+= grid[(posY+1)*SIZE+posX-1] + grid[(posY+1)*SIZE+posX+1]

    k+= grid[posY*SIZE+posX-1] + grid[posY*SIZE+posX+1]

    print k,

CROSSREFS

Cf. A214230.

Cf. A214252.

Sequence in context: A003635 A188631 A076764 * A031058 A084801 A106133

Adjacent sequences:  A214248 A214249 A214250 * A214252 A214253 A214254

KEYWORD

nonn,easy

AUTHOR

Alex Ratushnyak, Jul 08 2012

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 2 09:19 EDT 2020. Contains 335398 sequences. (Running on oeis4.)