%I #23 Jun 25 2021 21:20:10
%S 0,1,2,1,2,1,2,1,2,5,4,5,8,5,4,5,8,5,4,5,8,5,4,5,8,13,10,9,10,13,18,
%T 13,10,9,10,13,18,13,10,9,10,13,18,13,10,9,10,13,18,25,20,17,16,17,20,
%U 25,32,25,20,17,16,17,20,25,32,25,20,17,16,17,20,25,32
%N Squared distance from start of a point moving in a square spiral.
%C The terms corresponding to the corner points of the spiral with a(k-1) < a(k) > a(k+1), i.e., 2, 2, 2, 5, 8, 8, 8, 13, 18, 18, 18, ... are given by the sequence A001105(1) repeated 3 times, (A001105(1)+A001105(2))/2, A001105(2) repeated 3 times, (A001105(2)+A001105(3))/2, A001105(3) repeated 3 times, ... .
%C These numbers are the norms of the Gaussian integers discussed in A345436. - _N. J. A. Sloane_, Jun 25 2021
%H Hugo Pfoertner, <a href="/A336336/b336336.txt">Table of n, a(n) for n = 1..10000</a>
%H N. J. A. Sloane, <a href="/A336336/a336336.pdf">Sketch showing first 49 cells (numbered in black, starting at 0) of the square spiral and the corresponding squared distances from the origin (red).</a> (This illustration assumes the sequence has offset 0.)
%F a(n) = A174344(n)^2 + A268038(n)^2 = A174344(n)^2 + A274923(n)^2.
%o (PARI) A336336(m)={my(v=vectorsmall(m));for(Lstart=0,1,my(L=Lstart,d=1,n=0);for(r=1,oo,d=-d;my(k=floor(r/2)*d); for(j=1,L++,n++;if(n<=m,v[n]+=k*k));forstep(j=k-d,-floor((r+1)/2)*d+d,-d,n++;if(n<=m,v[n]+=j*j));if(n>m,break)));v};
%o A336336(73)
%Y Cf. A001105, A174344, A268038, A274923, A335298.
%Y See also A345436.
%K nonn
%O 1,3
%A _Hugo Pfoertner_, Jul 18 2020