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.

Showing 1-7 of 7 results.

A090861 Permutation of natural numbers arising from a spiral.

Original entry on oeis.org

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, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 49, 48, 47, 46, 45, 44, 43, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50
Offset: 1

Views

Author

Felix Tubiana, Feb 16 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 clockwise spiral: 1 -> 6 -> 5 -> 4 -> 3 -> 2 -> 9 -> etc.

Crossrefs

Programs

  • Mathematica
    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 *)
  • PARI
    {s(n)=floor((floor(sqrt(n-1)) +1)/2)};
    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
  • Sage
    def a(n):
        x = (isqrt(n-1)+1)//2
        return 8*x^2 + (-2 if n <= 4*x^2 + 2*x else 6)*x + 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

A090925 Permutation of natural numbers arising from a square spiral.

Original entry on oeis.org

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, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 26, 27, 28, 29, 30, 31, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80
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 counterclockwise spiral: 1 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 2 -> 3 -> 14 -> etc.

Crossrefs

Programs

  • Mathematica
    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 *)
  • PARI
    {s(n) = ((sqrtint(n-1)+1)/2)\1};
    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
  • Sage
    def a(n):
        x = (isqrt(n-1)+1)//2
        return n + 2*x if n + 2*x <= (2*x+1)^2 else n - 6*x
    [a(n) for n in (1..75)] # Eric M. Schmidt, May 18 2016
    

Extensions

Offset corrected by Eric M. Schmidt, May 18 2016

A090928 Permutation of natural numbers arising from a square spiral.

Original entry on oeis.org

1, 6, 7, 8, 9, 2, 3, 4, 5, 18, 19, 20, 21, 22, 23, 24, 25, 10, 11, 12, 13, 14, 15, 16, 17, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 50, 51, 52, 53, 54, 55, 56
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 counterclockwise spiral: 1 -> 6 -> 7 -> 8 -> 9 -> 2 -> 3 -> 4 -> 5 -> 18 -> etc.

Crossrefs

Programs

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

Formula

a(n) = A090925(A090925(n)). - Rémy Sigrist, Jul 25 2025

Extensions

Offset corrected by Eric M. Schmidt, May 18 2016

A090929 Permutation of natural numbers arising from a square spiral.

Original entry on oeis.org

1, 8, 9, 2, 3, 4, 5, 6, 7, 22, 23, 24, 25, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 44, 45, 46, 47, 48, 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 74, 75, 76, 77, 78, 79, 80, 81, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
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 counterclockwise spiral: 1 -> 8 -> 9 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 22 -> etc.

Crossrefs

Programs

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

Extensions

Offset corrected by Eric M. Schmidt, May 18 2016

A090930 Permutation of natural numbers arising from a square spiral.

Original entry on oeis.org

1, 2, 9, 8, 7, 6, 5, 4, 3, 12, 11, 10, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 30, 29, 28, 27, 26, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 56, 55, 54, 53, 52, 51, 50, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66
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 clockwise spiral: 1 -> 2 -> 9 -> 8 -> 7 -> 6 -> 5 -> 4 -> 3 -> 12 -> etc.

Crossrefs

Programs

  • Mathematica
    With[{x = Floor[(Floor[Sqrt[n-1]] +1)/2]}, Table[8*x^2 -n +2 +x*If[n <= 4*x^2 -2*x, -6, 2], {n, 1, 75}]] (* G. C. Greubel, Feb 05 2019 *)
  • PARI
    {s(n) = ((sqrtint(n-1)+1)/2)\1};
    for(n=1,75, print1(8*s(n)^2 -n +2 +s(n)*if(n <= 2*s(n)*(2*s(n)-1), -6, 2), ", ")) \\ G. C. Greubel, Feb 05 2019
  • Sage
    def a(n):
        x = (isqrt(n-1)+1)//2
        return 8*x^2 + (-6 if n <= 4*x^2 - 2*x else 2)*x + 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

A361207 An infinite 2d grid is filled with the positive integers by placing them clockwise around the lowest number with open neighbors. a(n) is then the n-th term when the grid is read as a clockwise square spiral.

Original entry on oeis.org

1, 2, 7, 3, 10, 4, 12, 5, 8, 16, 6, 15, 29, 17, 9, 20, 35, 21, 11, 23, 39, 24, 13, 18, 30, 46, 28, 14, 27, 45, 67, 47, 31, 19, 34, 53, 76, 54, 36, 22, 38, 58, 82, 59, 40, 25, 32, 48, 68, 92, 66, 44, 26, 43, 65, 91, 121, 93, 69, 49, 33, 52, 75, 102, 133, 103, 77
Offset: 1

Views

Author

John Tyler Rascoe, Mar 04 2023

Keywords

Comments

To begin, 1 is placed at square (x,y) = (0,0); this then becomes square s = 1. Integers are added sequentially to the open squares of the neighborhood around square s. The neighborhood of a square is defined as: east (x+1,y), south (x,y-1), west (x-1,y), and north (x,y+1). The order in which numbers may be added to a neighborhood is always east, south, west, then north.
Numbers are added to open squares in the neighborhood of square s following the given order. The next number added to the grid is always the smallest positive integer not yet present on the grid. If a filled square is encountered within the current square's neighborhood, the process moves to the next direction in the order. Once the process has cycled through all directions of the neighborhood of a given square s, the process is repeated at square s+1.
The filled grid is then read as a clockwise square spiral, oriented east starting at (0,0). a(n) is the n-th term along the square spiral.
Since each positive integer is added to the grid once, reading the grid as a spiral gives a permutation of the positive integers. Similar permutations can be created by expanding the neighborhood of s.

Examples

			The spiral begins:
.
                    41
.
                40  25  32
.
            39--24--13--18--30
.            |
        38  23  12---5-- 8--16  28
.            |   |           |
    37  22  11   4   1---2   6  14  26
.            |   |       |   |
        36  21  10---3---7  15  27
.            |               |
            35--20---9--17--29
.
                34  19  31
.
                    33
		

Crossrefs

Programs

  • Python
    # see linked program

A364130 An infinite 2d grid is filled with the positive integers by placing them clockwise in the narrow von Neumann's neighborhood of square s, the lowest number with open neighbors. a(n) is then the n-th term when the grid is read as a clockwise square spiral.

Original entry on oeis.org

1, 2, 8, 3, 15, 4, 22, 5, 10, 37, 6, 31, 32, 9, 12, 84, 85, 16, 18, 154, 155, 23, 26, 11, 38, 58, 57, 7, 50, 51, 52, 33, 64, 13, 96, 97, 98, 86, 17, 19, 172, 173, 174, 156, 24, 27, 73, 39, 59, 431, 430, 429, 43, 386, 387, 388, 389, 53, 34, 65, 14, 123, 124
Offset: 1

Views

Author

John Tyler Rascoe, Jul 09 2023

Keywords

Comments

This is a variant of A361207, where the size of a square's neighborhood is dependent on the value of that square rather than being of fixed size.
The neighborhood of square s is defined as the narrow von Neumann's neighborhood of radius s, see Zaitsev link. This consists of s squares in a straight line starting at square s, in each of the four directions east, south, west, and north.
To begin, 1 is placed at square (x,y) = (0,0); this then becomes square s = 1. Integers are then added sequentially to the open squares within the neighborhood of square s. The next number added to the grid is always the smallest positive integer not yet present on the grid.
Each direction of a square's neighborhood is first filled moving outwards before moving to the next direction. The order of cycling through the directions is always east, south, west, then north. Numbers are added to a given direction until either it is full, or a filled square is encountered. The process moves to the next direction regardless of any open squares remaining past the encountered filled square in that current direction of the neighborhood. Once the process has cycled through all directions of the neighborhood of a given square s, the process is repeated at square s+1.
The filled grid is then read as a clockwise square spiral, oriented east starting at (0,0). a(n) is the n-th term along the square spiral.

Examples

			For s = 2, the eastern and then southern directions are filled moving outward from s. Then in the western direction a filled square is encountered so the process moves on to the northern direction of 2's neighborhood.
For s = 3, starting in the eastern direction a filled square is immediately encountered. The process then moves to the southern direction even thought there are open squares remaining in the eastern direction of 3's neighborhood.
The spiral begins:
.
                    25
.
                    24
.
                    23      11
.
                    22---5--10
.                    |
    21  20  19  18   4   1---2   6   7
.                    |       |
            17  16  15---3---8
.
                        12   9
.
                        13
.
                        14
		

Crossrefs

Cf. A174344, A268038 (spiral coordinates).

Programs

  • Python
    # see linked program
Showing 1-7 of 7 results.