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.

A090915 Permutation of natural numbers arising from a square spiral.

Original entry on oeis.org

1, 8, 7, 6, 5, 4, 3, 2, 9, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 25, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 49, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58
Offset: 1

Views

Author

Felix Tubiana, Feb 26 2004

Keywords

Comments

Write out the natural numbers in a square counterclockwise spiral:
.
17--16--15--14--13
| |
18 5---4---3 12
| | | |
19 6 1---2 11
| | |
20 7---8---9--10
|
21--22--23--24--25
.
Now read off the numbers in a square clockwise spiral: 1 -> 8 -> 7 -> 6 -> 5 -> 4 -> 3 -> 2 -> 9 -> etc.

Crossrefs

Programs

  • Mathematica
    With[{x = Floor[(Floor[Sqrt[n-1]]+1)/2]}, Table[If[n==(2*x+1)^2, n, 8*x^2 -n+2], {n, 1, 75}]] (* G. C. Greubel, Feb 05 2019 *)
  • PARI
    {s(n) = ((sqrtint(n-1)+1)/2)\1};
    for(n=1,75, print1(if(n == (2*s(n)+1)^2, n, 8*s(n)^2-n+2), ", ")) \\ G. C. Greubel, Feb 05 2019
  • Sage
    def a(n):
        x = (isqrt(n-1)+1)//2
        return n if n == (2*x+1)^2 else 8*x^2 + 2 - n
    [a(n) for n in (1..75)] # Eric M. Schmidt, May 18 2016
    

Extensions

Offset corrected by Eric M. Schmidt, May 18 2016