login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A063826 Let 1, 2, 3, 4 represent moves to the right, down, left and up; this sequence describes the movements in the clockwise square spiral (a.k.a. Ulam Spiral). 48

%I #30 Jul 07 2023 16:01:06

%S 1,2,3,3,4,4,1,1,1,2,2,2,3,3,3,3,4,4,4,4,1,1,1,1,1,2,2,2,2,2,3,3,3,3,

%T 3,3,4,4,4,4,4,4,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,

%U 4,4,4,4,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4

%N Let 1, 2, 3, 4 represent moves to the right, down, left and up; this sequence describes the movements in the clockwise square spiral (a.k.a. Ulam Spiral).

%C Sequence starts with 1, 2, 3, then can be broken into groups of 8n+4 members, so if n is incremented, starting at 1, the groups follow the following pattern: 3 occurs at the beginning of the group, 4 then occurs 2n times, 1 occurs 2n+1 times, 2 occurs 2n+1 times, 3 occurs 2n+1 times; so each group has 8n+4 terms.

%C Simpler description: Groups of 2*(2n-1) + 2*(2n) = 8n - 2 terms, n = 1, 2, 3, ..., consisting of 2n-1 times 1, then 2n-1 times 2; then 2n times 3, then 2n times 4. The n-th group starts at index (4n - 6)n + 2 and ends at index (4n + 2)n - 1. - _M. F. Hasler_, Aug 08 2020

%H Harry J. Smith, <a href="/A063826/b063826.txt">Table of n, a(n) for n = 0..1000</a>

%H Dario Alpern, <a href="https://www.alpertron.com.ar/ULAM.HTM">Ulam's Spiral</a>

%H Adrian J. F. Leatherland, <a href="https://web.archive.org/web/20160424015805/http://yoyo.cc.monash.edu.au/~bunyip/primes/primeSpiral.htm">The mysterious Ulam spiral phenomenon</a>

%F 1 <= a(n) <= 4 with a(n) == floor(sqrt(4n + 1)) (mod 4). - _M. F. Hasler_, Aug 08 2020

%e Breaking into the groups, we have: 1, 2, 3 n=1: 3, 4, 4, 1, 1, 1, 2, 2, 2, 3, 3, 3, n=2: 3, 4, 4, 4, 4, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 n=3: 3, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 and so on.

%e The spiral of numbers which shows in which order the steps in direction right, down, left and up are made, is depicted for example in sequence A174344. - _M. F. Hasler_, Aug 08 2020

%t a[n_] := Mod[Floor[Sqrt[4*n + 1]] + 3, 4] + 1; Table[a[n], {n, 0, 104}] (* _Jean-François Alcover_, Nov 30 2016 adapted from PARI *)

%t Join[{1,2,3},Flatten[Table[{{3},PadRight[{},2n,4],Table[PadRight[{},2n+1,k],{k,3}]},{n,5}]]] (* _Harvey P. Dale_, Jun 29 2019 *)

%o (PARI) A063826(n)=(sqrtint(4*n+1)+3)%4+1 \\ To see the terms: apply(A063826, [0..99])

%Y Cf. A000267, A174344.

%K easy,nice,nonn

%O 0,2

%A Wai Ha Lee (Wainson(AT)hotmail.com), Aug 20 2001

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)