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).
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, 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, 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
Offset: 0
Examples
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. 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
Links
- Harry J. Smith, Table of n, a(n) for n = 0..1000
- Dario Alpern, Ulam's Spiral
- Adrian J. F. Leatherland, The mysterious Ulam spiral phenomenon
Programs
-
Mathematica
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 *) 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 *)
-
PARI
A063826(n)=(sqrtint(4*n+1)+3)%4+1 \\ To see the terms: apply(A063826, [0..99])
Formula
1 <= a(n) <= 4 with a(n) == floor(sqrt(4n + 1)) (mod 4). - M. F. Hasler, Aug 08 2020
Comments