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.

A214526 Manhattan distances between n and 1 in a square spiral with positive integers and 1 at the center.

This page as a plain text file.
%I A214526 #36 Oct 25 2019 11:16:43
%S A214526 0,1,2,1,2,1,2,1,2,3,2,3,4,3,2,3,4,3,2,3,4,3,2,3,4,5,4,3,4,5,6,5,4,3,
%T A214526 4,5,6,5,4,3,4,5,6,5,4,3,4,5,6,7,6,5,4,5,6,7,8,7,6,5,4,5,6,7,8,7,6,5,
%U A214526 4,5,6,7,8,7,6,5,4,5,6,7,8,9,8,7,6,5,6,7,8,9,10,9,8,7,6,5,6,7,8,9,10,9,8,7,6,5,6,7,8,9,10,9,8,7,6,5,6,7,8,9,10
%N A214526 Manhattan distances between n and 1 in a square spiral with positive integers and 1 at the center.
%C A214526 Spiral begins:
%C A214526   49  26--27--28--29--30--31
%C A214526    |   |                   |
%C A214526   48  25  10--11--12--13  32
%C A214526    |   |   |           |   |
%C A214526   47  24   9   2---3  14  33
%C A214526    |   |   |   |   |   |   |
%C A214526   46  23   8   1   4  15  34
%C A214526    |   |   |       |   |   |
%C A214526   45  22   7---6---5  16  35
%C A214526    |   |               |   |
%C A214526   44  21--20--19--18--17  36
%C A214526    |                       |
%C A214526   43--42--41--40--39--38--37
%H A214526 Michael De Vlieger, <a href="/A214526/b214526.txt">Table of n, a(n) for n = 1..10201</a>
%F A214526 abs( a(n) - a(n-1) ) = 1.
%F A214526 For n > 1, a(n) = layer(n) + abs(((n-1) mod (2*layer(n)) - layer(n))) (conjectured) where layer(n) = ceiling(0.5*sqrt(n) - 0.5). - _Karl R. Stephan_, Jan 26 2018
%F A214526 a(n) = abs(A174344(n)) + abs(A274923(n)). - _Kevin Ryde_, Oct 25 2019
%t A214526 f[n_] := Block[{o = 2 n - 1, t, w}, t = Table[0, {o}, {o}]; t = ReplacePart[t, {n, n} -> 1]; Do[w = Partition[Range[(2 (# - 1) - 1)^2 + 1, (2 # - 1)^2], 2 (# - 1)] &@ k; Do[t = ReplacePart[t, {(n + k) - (j + 1), n + (k - 1)} -> #[[1, j]]]; t = ReplacePart[t, {n - (k - 1), (n + k) - (j + 1)} -> #[[2, j]]]; t = ReplacePart[t, {(n - k) + (j + 1), n - (k - 1)} -> #[[3, j]]]; t = ReplacePart[t, {n + (k - 1), (n - k) + (j + 1)} -> #[[4, j]]], {j, 2 (k - 1)}] &@ w, {k, 2, n}]; t]; With[{x = Position[#, 1][[1]]}, Table[Total@ Abs[Position[#, n][[1]] - x], {n, Max@ #}]] &@ f@ 6 (* _Michael De Vlieger_, Feb 16 2018 *)
%o A214526 (PARI) a(n) = n--; my(m=sqrtint(n),k=ceil(m/2)); n=abs(n-4*k^2); k+abs(n-if(n>m,3,1)*k); \\ _Kevin Ryde_, Oct 25 2019
%Y A214526 Cf. A137928, A137930, A137931, A002061, A114254, A214176, A214177.
%K A214526 nonn,easy
%O A214526 1,3
%A A214526 _Alex Ratushnyak_, Aug 08 2012