

A296030


Pairs of coordinates for successive integers in the square spiral (counterclockwise).


13



0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 2, 1, 2, 0, 2, 1, 2, 2, 1, 2, 0, 2, 1, 2, 2, 2, 2, 1, 2, 0, 2, 1, 2, 2, 1, 2, 0, 2, 1, 2, 2, 2, 3, 2, 3, 1, 3, 0, 3, 1, 3, 2, 3, 3, 2, 3, 1, 3, 0, 3, 1, 3, 2, 3, 3, 3, 3, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,19


COMMENTS

The spiral is also called the Ulam spiral, cf. A174344, A274923 (x and y coordinates).  M. F. Hasler, Oct 20 2019
The nth positive integer occupies the point whose x and ycoordinates are represented in the sequence by a(2n1) and a(2n), respectively.  Robert G. Wilson v, Dec 03 2017
From Robert G. Wilson v, Dec 05 2017: (Start)
The cover of the March 1964 issue of Scientific American (see link) depicts the Ulam Spiral with a heavy black line separating the numbers from their nonsequential neighbors. The pairs of coordinates for the points on this line, assuming it starts at the origin, form this sequence, negated.
The first number which has an abscissa value of k beginning at 0: 1, 2, 10, 26, 50, 82, 122, 170, 226, 290, 362, 442, 530, 626, 730, 842, 962, ...; g.f.: (x^3 +7x^2 x +1)/(x1)^3;
The first number which has an abscissa value of k beginning at 0: 1, 5, 17, 37, 65, 101, 145, 197, 257, 325, 401, 485, 577, 677, 785, 901, ...; g.f.: (5x^2 +2x +1)/(x1)^3;
The first number which has an ordinate value of k beginning at 0: 1, 3, 13, 31, 57, 91, 133, 183, 241, 307, 381, 463, 553, 651, 757, 871, 993, ...; g.f.: (7x^2+1)/(x1)^3;
The first number which has an ordinate value of k beginning at 0: 1, 7, 21, 43, 73, 111, 157, 211, 273, 343, 421, 507, 601, 703, 813, 931, ...; g.f.: (3x^2+4x+1)/(x1)^3;
The union of the four sequences above is A033638.
(End)
Sequences A174344, A268038 and A274923 start with the integer 0 at the origin (0,0). One might then prefer offset 0 as to have (a(2n), a(2n+1)) as coordinates of the integer n.  M. F. Hasler, Oct 20 2019
This sequence can be read as an infinite table with 2 columns, where row n gives the x and ycoordinate of the nth point on the spiral. If the point at the origin has number 0, then the points with coordinates (n,n), (n,n), (n,n) and (n,n) have numbers given by A002939(n) = 2n(2n1): (0, 2, 12, 30, ...), A016742(n) = 4n^2: (0, 4, 16, 36, ...), A002943(n) = 2n(2n+1): (0, 6, 20, 42, ...) and A033996(n) = 4n(n+1): (0, 8, 24, 48, ...), respectively.  M. F. Hasler, Nov 02 2019


LINKS

Benjamin Mintz, Table of n, a(n) for n = 1..100000
BackIssues.com, Scientific American March 1964 back issue
Scientific American, March 1964 cover
Wikipedia, Ulam Spiral.


FORMULA

a(2n1) = A174344(n).
a(2n) = A274923(n) = A268038(n).
abs(a(n+2)  a(n)) < 2.
a(2n1)+a(2n) = A180714(n).


EXAMPLE

The integer 1 occupies the initial position so its coordinates are {0,0}; therefore a(1)=0 and a(2)=0.
The integer 2 occupies the position immediately to the right of 1 so its coordinates are {1,0}.
The integer 3 occupies the position immediately above 2 so its coordinates are {1,1}; etc.


MATHEMATICA

f[n_] := Block[{k = Ceiling[(Sqrt[n]  1)/2], m, t}, t = 2k +1; m = t^2; t; If[n >= m  t, {k (m  n), k}, m = t; If[n >= m  t, {k, k +(m  n)}, m = t; If[n >= m  t, {k +(m  n), k}, {k, k (m  n  t)}]]]]; Array[f, 40] // Flatten (* Robert G. Wilson v, Dec 04 2017 *)
f[n_] := Block[{k = Mod[ Floor[ Sqrt[4 If[OddQ@ n, (n + 1)/2  2, (n/2  2)] + 1]], 4]}, f[n  2] + If[OddQ@ n, Sin[k*Pi/2], Cos[k*Pi/2]]]; f[1] = f[2] = 0; Array[f, 90] (* Robert G. Wilson v, Dec 14 2017 *)


PROG

(Python) def get_coordinate(n):
....k=ceil((sqrt(n)1)/2)
....t=2*k+1
....m=t**2
....t=t1
....if n >= m  t:
........return k  (mn), k
....else:
........m = t
....if n >= m  t:
........return k, k+(mn)
....else:
........m = t
....if n >= mt:
........return k+(mn), k
....else:
........return k, k(mnt)
(PARI) apply( {coords(n)=my(m=sqrtint(n), k=m\/2); if(m <= n = 4*k^2, [n3*k, k], n >= 0, [k, kn], n >= m, [kn, k], [k, 3*k+n])}, [0..99]) \\ Use concat(%) to remove brackets '[', ']'. This function gives the coordinates of n on the spiral starting with 0 at (0, 0), as shown in Examples for A174344, A274923, ..., so (a(2n1), a(2n)) = coords(n1). To start with 1 at (0, 0), change n to n=1 in sqrtint(). The inverse function is pos(x, y) given e.g. in A316328.  M. F. Hasler, Oct 20 2019


CROSSREFS

Cf. A033638, A063826, A174344, A180714, A268038, A274923.
Cf. Diagonal rays (+n,+n): A002939 (2n(2n1): 0, 2, 12, 30, ...: NE), A016742 (4n^2: 0, 4, 16, 36, ...: NW), A002943 (2n(2n+1): 0, 6, 20, 42, ...: SW) and A033996 (4n(n+1): 0, 8, 24, 48, ...: SE).
Sequence in context: A165034 A193347 A115862 * A270144 A255980 A029357
Adjacent sequences: A296027 A296028 A296029 * A296031 A296032 A296033


KEYWORD

sign,easy,look,changed


AUTHOR

Benjamin Mintz, Dec 03 2017


STATUS

approved



