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-10 of 12 results. Next

A217010 Permutation of natural numbers arising from applying the walk of a square spiral (e.g., A214526) to the data of right triangular type-1 spiral (defined in A214230).

Original entry on oeis.org

1, 2, 13, 3, 5, 6, 7, 8, 9, 10, 12, 32, 61, 33, 14, 4, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 11, 31, 60, 98, 145, 99, 62, 34, 15, 17, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 28, 30, 59, 97, 144, 200, 265, 201, 146, 100, 63, 35, 16, 39, 71
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

Examples

			Triangular spiral (A214230) begins:
.
  56
   | \
  55  57
   |     \
  54  29  58
   |   | \   \
  53  28  30  59
   |   |     \   \
  52  27  11  31  60
   |   |   | \   \   \
  51  26  10  12  32  61
   |   |   |     \   \   \
  50  25   9   2  13  33  62
   |   |   |   | \   \   \   \
  49  24   8   1   3  14  34  63
   |   |   |         \   \   \   \
  48  23   7---6---5---4  15  35  64
   |   |                     \   \   \
  47  22--21--20--19--18--17--16  36  65
   |                                 \   \
  46--45--44--43--42--41--40--39--38--37  66
                                             \
  78--77--76--75--74--73--72--71--70--69--68--67
.
Square spiral (defining order in which elements are fetched) begins:
.
  49  26--27--28--29--30--31
   |   |                   |
  48  25  10--11--12--13  32
   |   |   |           |   |
  47  24   9   2---3  14  33
   |   |   |   |   |   |   |
  46  23   8   1   4  15  34
   |   |   |       |   |   |
  45  22   7---6---5  16  35
   |   |               |   |
  44  21--20--19--18--17  36
   |                       |
  43--42--41--40--39--38--37
		

Crossrefs

Programs

  • Python
    SIZE = 33       # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk(0, -1,  1,  1)    # up
        walk( 1, 1, -1,  0)    # right-down
        if posX==SIZE-1:
            break
        walk(-1, 0,  0, -1)    # left
    import sys
    grid2 = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid2[posY*SIZE+posX]=1
    def walk2(stepX, stepY, chkX, chkY):
      global posX, posY
      while 1:
        a = grid[posY*SIZE+posX]
        if a==0:
            sys.exit(1)
        print(a, end=', ')
        posX+=stepX
        posY+=stepY
        grid2[posY*SIZE+posX]=1
        if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posX:
        walk2(0, -1, 1, 0)    # up
        walk2(1, 0, 0, 1)     # right
        walk2(0, 1, -1, 0)    # down
        walk2(-1, 0, 0, -1)   # left

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

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

A217015 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of rotated-square spiral (defined in A215468).

Original entry on oeis.org

1, 5, 6, 2, 8, 3, 10, 4, 12, 24, 13, 14, 27, 15, 7, 17, 31, 18, 9, 20, 35, 21, 11, 23, 39, 59, 40, 25, 26, 43, 64, 44, 28, 16, 30, 48, 70, 49, 32, 19, 34, 53, 76, 54, 36, 22, 38, 58, 82, 110, 83, 60, 41, 42, 63, 88, 117, 89, 65, 45, 29, 47, 69, 95, 125, 96, 71, 50
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 33       # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    posX += 1
    grid[posY*SIZE+posX]=2
    n = 3
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posX!=SIZE-1:
        walk(-1,  1, -1, -1)    # down-left
        walk(-1, -1,  1, -1)    # up-left
        walk( 1, -1,  1,  0)    # up-right
        walk( 1,  0,  1,  1)    # right
        walk( 1,  1, -1,  1)    # down-right
    import sys
    grid2 = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid2[posY*SIZE+posX]=1
    def walk2(stepX, stepY, chkX, chkY):
      global posX, posY
      while 1:
        a = grid[posY*SIZE+posX]
        if a==0:
            sys.exit(1)
        print(a, end=', ')
        posX+=stepX
        posY+=stepY
        grid2[posY*SIZE+posX]=1
        if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk2(0, -1, 1, 0)    # up
        walk2(1, 0, 0, 1)     # right
        walk2(0, 1, -1, 0)    # down
        walk2(-1, 0, 0, -1)   # left

A217011 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of right triangular type-2 spiral (defined in A214251).

Original entry on oeis.org

1, 5, 19, 6, 8, 9, 10, 2, 3, 4, 18, 41, 73, 42, 20, 7, 24, 25, 26, 27, 28, 11, 12, 13, 14, 15, 17, 40, 72, 113, 163, 114, 74, 43, 21, 23, 49, 50, 51, 52, 53, 54, 55, 29, 30, 31, 32, 33, 34, 35, 16, 39, 71, 112, 162, 221
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 33       # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk(-1, 0,  0, -1)    # left
        walk(0, -1,  1,  1)    # up
        if posY==0:
            break
        walk( 1, 1, -1,  0)    # right-down
    import sys
    grid2 = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid2[posY*SIZE+posX]=1
    def walk2(stepX, stepY, chkX, chkY):
      global posX, posY
      while 1:
        a = grid[posY*SIZE+posX]
        if a==0:
            sys.exit(1)
        print(a, end=', ')
        posX+=stepX
        posY+=stepY
        grid2[posY*SIZE+posX]=1
        if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk2(0, -1, 1, 0)    # up
        walk2(1, 0, 0, 1)     # right
        walk2(0, 1, -1, 0)    # down
        walk2(-1, 0, 0, -1)   # left

A217012 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of right triangular type-3 spiral (defined in A214252).

Original entry on oeis.org

1, 8, 25, 9, 2, 3, 4, 5, 6, 7, 24, 50, 85, 51, 26, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 49, 84, 128, 181, 129, 86, 52, 27, 11, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 22, 48, 83, 127, 180, 242
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 33       # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posY!=0:
        walk( 1, 1, -1,  0)    # right-down
        walk(-1, 0,  0, -1)    # left
        walk(0, -1,  1,  1)    # up
    import sys
    grid2 = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid2[posY*SIZE+posX]=1
    def walk2(stepX, stepY, chkX, chkY):
      global posX, posY
      while 1:
        a = grid[posY*SIZE+posX]
        if a==0:
            sys.exit(1)
        print(a, end=', ')
        posX+=stepX
        posY+=stepY
        grid2[posY*SIZE+posX]=1
        if grid2[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while 1:
        walk2(0, -1, 1, 0)    # up
        walk2(1, 0, 0, 1)     # right
        walk2(0, 1, -1, 0)    # down
        walk2(-1, 0, 0, -1)   # left

A217013 Permutation of natural numbers arising from applying the walk of a square spiral (e.g. A214526) to the data of triangular horizontal-first spiral (defined in A214250).

Original entry on oeis.org

1, 3, 14, 4, 6, 7, 8, 2, 12, 30, 13, 32, 59, 33, 15, 5, 19, 20, 21, 22, 23, 9, 11, 29, 55, 89, 56, 31, 58, 93, 136, 94, 60, 34, 16, 18, 40, 41, 42, 43, 44, 45, 46, 24, 10, 28, 54, 88, 130, 180, 131, 90, 57, 92, 135, 186, 245, 187, 137, 95, 61, 35, 17, 39, 69
Offset: 1

Views

Author

Alex Ratushnyak, Sep 23 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 33       # must be 4k+1
    grid = [0] * (SIZE*SIZE)
    posX = posY = SIZE//2
    grid[posY*SIZE+posX]=1
    n = 2
    def walk(stepX, stepY, chkX, chkY):
      global posX, posY, n
      while 1:
        posX+=stepX
        posY+=stepY
        grid[posY*SIZE+posX]=n
        n+=1
        if grid[(posY+chkY)*SIZE+posX+chkX]==0:
            return
    while posX
    				
Showing 1-10 of 12 results. Next