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.

A090861 Permutation of natural numbers arising from a spiral.

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