The OEIS is supported by the many generous donors to the OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A215468 Sum of the 8 nearest neighbors of n in a rotated-square spiral with positive integers. 5
 50, 62, 72, 86, 76, 84, 122, 88, 144, 104, 166, 120, 152, 160, 144, 218, 160, 168, 248, 184, 192, 278, 208, 216, 260, 268, 240, 248, 346, 264, 272, 280, 384, 296, 304, 312, 422, 328, 336, 344, 400, 408, 368, 376, 384, 506, 400, 408, 416, 424, 552, 440, 448, 456, 464, 598 (list; graph; refs; listen; history; text; internal format)
 OFFSET 1,1 LINKS EXAMPLE Spiral begins:                      85                      /                     /                   84 61-62                   /  /    \                  /  /      \                83 60 41-42 63                /  /  /    \  \               /  /  /      \  \             82 59 40 25-26 43 64             /  /  /  /    \  \  \            /  /  /  /      \  \  \          81 58 39 24 13-14 27 44 65          /  /  /  /  /    \  \  \  \         /  /  /  /  /      \  \  \  \       80 57 38 23 12  5--6 15 28 45 66       /  /  /  /  /  /    \  \  \  \  \      /  /  /  /  /  /      \  \  \  \  \    79 56 37 22 11  4  1--2  7 16 29 46 67      \  \  \  \  \  \   /  /  /  /  /  /       \  \  \  \  \  \ /  /  /  /  /  /       78 55 36 21 10  3  8 17 30 47 68         \  \  \  \  \   /  /  /  /  /          \  \  \  \  \ /  /  /  /  /          77 54 35 20  9 18 31 48 69            \  \  \  \   /  /  /  /             \  \  \  \ /  /  /  /             76 53 34 19 32 49 70               \  \  \   /  /  /                \  \  \ /  /  /                75 52 33 50 71                  \  \   /  /                   \  \ /  /                   74 51 72                     \   /                      \ /                      73 . The 8 nearest neighbors of 4 are 1,3,5,10,11,12,21,23, their sum is 86, so a(4)=86. PROG (Python) SIZE=17  # must be odd grid = [0] * (SIZE*SIZE) posX = posY = SIZE//2 saveX = [0]* (SIZE*SIZE+1) saveY = [0]* (SIZE*SIZE+1) grid[posY*SIZE+posX]=1 saveX[1]=posX saveY[1]=posY posX += 1 grid[posY*SIZE+posX]=2 saveX[2]=posX saveY[2]=posY n = 3 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 grid[(posY+chkY)*SIZE+posX+chkX]==0:         return while posX!=SIZE-1:     walk(-1,  1, -1, -1)    # down-left     walk(-1, -1,  1, -1)    # up-left     walk( 1, -1,  1,  0)    # up-right     walk( 1,  0,  1,  1)    # right     walk( 1,  1, -1,  1)    # down-right for s in range(1, n):     posX = saveX[s]     posY = saveY[s]     i, j = grid[(posY-1)*SIZE+posX-1], grid[(posY-1)*SIZE+posX+1]     u, v = grid[(posY+1)*SIZE+posX-1], grid[(posY+1)*SIZE+posX+1]     if i==0 or j==0 or u==0 or v==0:         break     k = grid[(posY-1)*SIZE+posX  ] + grid[(posY+1)*SIZE+posX  ]     k+= grid[ posY   *SIZE+posX-1] + grid[ posY   *SIZE+posX+1]     print i+j+u+v+k, print for y in range(SIZE):     for x in range(SIZE):         print '%3d' % grid[y*SIZE+x],     print CROSSREFS Coordinates (but 0-based): A010751, A305258. Other spiral sums: A214176, A214177, A214226, A214227, A214230, A214231, A214250, A214251, A214252. Sequence in context: A062118 A167329 A179796 * A109552 A206263 A007692 Adjacent sequences:  A215465 A215466 A215467 * A215469 A215470 A215471 KEYWORD nonn,easy AUTHOR Alex Ratushnyak, Aug 11 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 | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified August 14 17:36 EDT 2022. Contains 356122 sequences. (Running on oeis4.)