cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A304586 A linear mapping a(n) = x + d*n of pairs of integers (x,d), where the pairs are enumerated by the counterclockwise square spiral (an axis-parallel number spiral) starting at 0.

This page as a plain text file.
%I A304586 #26 Oct 21 2019 02:23:36
%S A304586 0,1,3,3,3,-1,-7,-7,-7,-7,2,13,26,27,28,29,30,15,-2,-21,-42,-43,-44,
%T A304586 -45,-46,-47,-23,3,31,61,93,95,97,99,101,103,105,71,35,-3,-43,-85,
%U A304586 -129,-131,-133,-135,-137,-139,-141,-143,-96,-47,4,57,112,169,228,231,234,237,240,243
%N A304586 A linear mapping a(n) = x + d*n of pairs of integers (x,d), where the pairs are enumerated by the counterclockwise square spiral (an axis-parallel number spiral) starting at 0.
%C A304586 The sequence is a solution to the riddle described in the comments of A304584 without the restriction of x and d to nonnegative numbers.
%H A304586 Rainer Rosenthal, <a href="/A304586/b304586.txt">Table of n, a(n) for n = 0..10000</a>
%e A304586 This is the standard counterclockwise square spiral starting at 0. - _N. J. A. Sloane_, Oct 17 2019
%e A304586 d:
%e A304586    3 |  36--35--34--33--32--31--30  55
%e A304586      |   |                       |   |
%e A304586    2 |  37  16--15--14--13--12  29  54
%e A304586      |   |   |               |   |   |
%e A304586    1 |  38  17   4---3---2  11  28  53
%e A304586      |   |   |   |       |   |   |   |
%e A304586    0 |  39  18   5   0---1  10  27  52
%e A304586      |   |   |   |           |   |   |
%e A304586   -1 |  40  19   6---7---8---9  26  51
%e A304586      |   |   |                   |   |
%e A304586   -2 |  41  20--21--22--23--24--25  50
%e A304586      |   |                           |
%e A304586   -3 |  42--43--44--45--46--47--48--49
%e A304586      _________________________________
%e A304586   x:    -3  -2  -1   0   1   2   3   4
%e A304586 .
%e A304586 a(9) = 2 + 9*(-1) = -7 because the 9th position in the spiral corresponds to x = 2 and d = -1,
%e A304586 a(14) = 0 + 14*2 = 28 because the 14th position in the spiral corresponds to x = 0 and d = 2,
%e A304586 a(25) = 3 + 25*(-2) = -47 because the 25th position in the spiral corresponds to x = 3 and d = -2.
%p A304586 square2pair:=proc(sq)local w,k;w:=floor(sqrt(sq));k:=floor(w/2);if modp(sq,2)=0 then return[-k,k];else return[k+1,-k];fi;end:pos2pS:=proc(n)local w,q,Q,e,E,sp;w:=floor(sqrt(n));q := w^2;Q:=(w+1)^2;e:=n-q;E:=Q-n;if e<E then sp:=square2pair(q);if modp(q,2)=0 then return[sp[1],sp[2]-e];else return[sp[1],sp[2]+e];fi;else sp:=square2pair(Q);if modp(Q,2)=0 then return[sp[1]+E,sp[2]];else return[sp[1]-E,sp[2]];fi;fi;end:WhereFlea:=proc(n) local x,d,pair; pair:=pos2pS(n);x:=pair[1];d:=pair[2];return x+d*n;end: seq(WhereFlea(n),n=0..61);# _Rainer Rosenthal_, May 24 2018
%Y A304586 Cf. A174344, A274923, A304584, A304585, A304587.
%K A304586 sign,look
%O A304586 0,3
%A A304586 _Hugo Pfoertner_, May 16 2018
%E A304586 a(1) and a(2) corrected by _Rainer Rosenthal_, May 24 2018