login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A174344 List of x-coordinates of point moving in clockwise square spiral. 13
0, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,10

COMMENTS

Also, list of x-coordinates of point moving in counterclockwise square spiral.

This spiral, in either direction, is sometimes called the "Ulam spiral", but "square spiral" is a better name. (Ulam looked at the positions of the primes, but of course the spiral itself must be much older.) - N. J. A. Sloane, Jul 17 2018

LINKS

Peter Kagey, Table of n, a(n) for n = 1..10000

S. Mustonen, Ulam spiral in color

Aaron Snook, Augmented Integer Linear Recurrences, Thesis, 2012.

FORMULA

From Seppo Mustonen, Aug 21 2010 with correction by Peter Kagey, Jan 24 2016: (Start)

a(1) = 0, a(n) = a(n-1) + sin(mod(floor(sqrt(4*(n-2)+1)),4)*Pi/2).

For a corresponding formula for the y-coordinate, replace sin by cos. (End)

EXAMPLE

Here is the beginning of the clockwise square spiral. Sequence gives x-coordinate of the n-th point.

.

  20--21--22--23--24--25

   |                   |

  19   6---7---8---9  26

   |   |           |   |

  18   5   0---1  10  27

   |   |       |   |   |

  17   4---3---2  11  28

   |               |   |

  16--15--14--13--12  29

                       |

  35--34--33--32--32--30

.

MAPLE

fx:=proc(n) option remember; local k; if n=1 then 0 else

k:=floor(sqrt(4*(n-2)+1)) mod 4;

fx(n-1) + sin(k*Pi/2); fi; end;

[seq(fx(n), n=1..120)]; # Based on Seppo Mustonen's formula. - N. J. A. Sloane, Jul 11 2016

MATHEMATICA

a[n_]:=a[n]=If[n==0, 0, a[n-1]+Sin[Mod[Floor[Sqrt[4*(n-1)+1]], 4]*Pi/2]]; Table[a[n], {n, 0, 50}] (* Seppo Mustonen, Aug 21 2010 *)

PROG

(PARI) L=0; d=1;

for(r=1, 9, d=-d; k=floor(r/2)*d; for(j=1, L++, print1(k, ", ")); forstep(j=k-d, -floor((r+1)/2)*d+d, -d, print1(j, ", "))) \\ Hugo Pfoertner, Jul 28 2018

(Julia)

function SquareSpiral(len)

    x, y, i, j, N, n, c = 0, 0, 0, 0, 0, 0, 0

    for k in 0:len-1

        print("$x, ") # or print("$y, ") for A268038.

        if n == 0

            c += 1; c > 3 && (c =  0)

            c == 0 && (i = 0; j =  1)

            c == 1 && (i = 1; j =  0)

            c == 2 && (i = 0; j = -1)

            c == 3 && (i = -1; j = 0)

            c in [1, 3] && (N += 1)

            n = N

        end

        n -= 1

        x, y = x + i, y + j

end end

SquareSpiral(75) # Peter Luschny, May 05 2019

CROSSREFS

Cf. A180714. A268038 (or A274923) gives sequence of y-coordinates.

The (x,y) coordinates for a point sweeping a quadrant by antidiagonals are (A025581, A002262). - N. J. A. Sloane, Jul 17 2018

Sequence in context: A124752 A293730 A318722 * A049241 A321858 A230415

Adjacent sequences:  A174341 A174342 A174343 * A174345 A174346 A174347

KEYWORD

sign

AUTHOR

Nikolas Garofil (nikolas(AT)garofil.be), Mar 16 2010

EXTENSIONS

Link corrected by Seppo Mustonen, Sep 05 2010

Clarified definition - N. J. A. Sloane, Dec 20 2012

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 23 22:38 EDT 2019. Contains 325278 sequences. (Running on oeis4.)