OFFSET
1,3
COMMENTS
Enter 1 into center position of the spiral. Repeat: Go to next position of the spiral and enter into that position the sum of the numbers in those already filled positions that are horizontally, vertically or diagonally adjacent to it.
Clockwise and counterclockwise construction of the spiral result in the same sequence.
LINKS
Klaus Brockhaus, Table of n, a(n) for n=1..961
Eric Wastl, Day 3 Spiral Memory Part Two, Advent of Code 2017.
EXAMPLE
Clockwise constructed spiral begins
.
362--747--806--880--931
|
351 11---23---25---26
| | |
330 10 1----1 54
| | | |
304 5----4----2 57
| |
147--142--133--122---59
PROG
(PARI) {m=5; h=2*m-1; A=matrix(h, h); print1(A[m, m]=1, ", "); T=[[1, 0], [1, -1], [0, -1], [ -1, -1], [ -1, 0], [ -1, 1], [0, 1], [1, 1]]; for(n=1, (h-2)^2-1, g=sqrtint(n); r=(g+g%2)\2; q=4*r^2; d=n-q; if(n<=q-2*r, j=d+3*r; k=r, if(n<=q, j=r; k=-d-r, if(n<=q+2*r, j=r-d; k=-r, j=-r; k=d-3*r))); j=j+m; k=k+m; s=0; for(c=1, 8, v=[j, k]; v+=T[c]; s=s+A[v[1], v[2]]); A[j, k]=s; print1(s, ", "))} \\ Klaus Brockhaus, Aug 27 2008
CROSSREFS
KEYWORD
nonn
AUTHOR
Niclas Rantala (nrantala(AT)hotmail.com), Aug 09 2008
EXTENSIONS
Edited and extended beyond a(9) by Klaus Brockhaus, Aug 27 2008
STATUS
approved