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.

A090925 Permutation of natural numbers arising from a square spiral.

This page as a plain text file.
%I A090925 #15 Jul 05 2022 11:12:46
%S A090925 1,4,5,6,7,8,9,2,3,14,15,16,17,18,19,20,21,22,23,24,25,10,11,12,13,32,
%T A090925 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,26,27,28,29,30,31,
%U A090925 58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80
%N A090925 Permutation of natural numbers arising from a square spiral.
%C A090925 Write out the natural numbers in a square counterclockwise spiral:
%C A090925 .
%C A090925   17--16--15--14--13
%C A090925    |               |
%C A090925   18   5---4---3  12
%C A090925    |   |       |   |
%C A090925   19   6   1---2  11
%C A090925    |   |           |
%C A090925   20   7---8---9--10
%C A090925    |
%C A090925   21--22--23--24--25
%C A090925 .
%C A090925 Now read off the numbers in a square counterclockwise spiral: 1 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 2 -> 3 -> 14 -> etc.
%H A090925 Eric M. Schmidt, <a href="/A090925/b090925.txt">Table of n, a(n) for n = 1..1000</a>
%t A090925 With[{x = Floor[(Floor[Sqrt[n-1]]+1)/2]}, Table[If[n+2*x <= (2*x+1)^2, n +2*x, n-6*x], {n, 1, 75}]] (* _G. C. Greubel_, Feb 05 2019 *)
%o A090925 (Sage)
%o A090925 def a(n):
%o A090925     x = (isqrt(n-1)+1)//2
%o A090925     return n + 2*x if n + 2*x <= (2*x+1)^2 else n - 6*x
%o A090925 [a(n) for n in (1..75)] # _Eric M. Schmidt_, May 18 2016
%o A090925 (PARI) {s(n) = ((sqrtint(n-1)+1)/2)\1};
%o A090925 for(n=1,75, print1(if(n+2*s(n) <= (2*s(n)+1)^2, n +2*s(n), n - 6*s(n)), ", ")) \\ _G. C. Greubel_, Feb 05 2019
%Y A090925 Cf. A020703, A090861, A090915, A090928, A090929, A090930.
%K A090925 easy,nonn
%O A090925 1,2
%A A090925 _Felix Tubiana_, Feb 26 2004
%E A090925 Offset corrected by _Eric M. Schmidt_, May 18 2016