A214230 Sum of the eight nearest neighbors of n in a right triangular type-1 spiral with positive integers.
53, 88, 78, 125, 85, 84, 125, 97, 108, 143, 223, 168, 158, 169, 201, 284, 208, 183, 179, 187, 210, 281, 226, 219, 227, 235, 261, 314, 430, 339, 311, 310, 318, 326, 346, 396, 515, 403, 360, 347, 355, 363, 371, 379, 411, 509, 427, 411, 419, 427, 435, 443, 451, 486, 557
Offset: 1
Examples
Right triangular spiral begins: 56 55 57 54 29 58 53 28 30 59 52 27 11 31 60 51 26 10 12 32 61 50 25 9 2 13 33 62 49 24 8 1 3 14 34 63 48 23 7 6 5 4 15 35 64 47 22 21 20 19 18 17 16 36 65 46 45 44 43 42 41 40 39 38 37 66 78 77 76 75 74 73 72 71 70 69 68 67 The eight nearest neighbors of 3 are 1, 2, 13, 33, 14, 4, 5, 6. Their sum is a(3)=78.
Links
- David Radcliffe, Table of n, a(n) for n = 1..10000
Programs
-
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(0, -1, 1, 1) # up if posY==0: break walk( 1, 1, -1, 0) # right-down walk(-1, 0, 0, -1) # left 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, end=', ')
Comments