OFFSET
0,4
COMMENTS
LINKS
Peter Kagey, Table of n, a(n) for n = 0..2499
EXAMPLE
Spiral begins:
3----2----1
| |
5 1----1 47
| |
8---11---21---40
a(11) = 47 = 1 + 1 + 5 + 40, the sum of the cells in its row and column.
PROG
P(n)={my(m=sqrtint(n), k=ceil(m/2)); n -= 4*k^2; if(n<0, if(n<-m, [k, 3*k+n], [-k-n, k]), if(n<m, [-k, k-n], [n-3*k, -k]))}
seq(n)={my(m=sqrtint(n)+1, k=ceil(m/2), sx=vector(m), sy=vector(m), v=vector(1+n)); v[1]=sx[k]=sy[k]=1; for(i=1, n, my([px, py]=P(i)); px+=k; py+=k; my(t=sx[px]+sy[py]); sx[px]+=t; sy[py]+=t; v[i+1]=t); v} \\ Andrew Howroyd, May 09 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Alec Jones and Peter Kagey, May 09 2020
STATUS
approved