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.

Previous Showing 11-20 of 26 results. Next

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

Original entry on oeis.org

1, 8, 2, 4, 16, 5, 6, 7, 22, 45, 23, 9, 11, 3, 15, 35, 63, 36, 17, 18, 19, 20, 21, 44, 75, 114, 76, 46, 24, 10, 28, 12, 14, 34, 62, 98, 142, 99, 64, 37, 38, 39, 40, 41, 42, 43, 74, 113, 160, 215, 161, 115, 77, 47, 25, 27, 53, 29, 13, 33, 61, 97, 141, 193, 253
Offset: 1

Views

Author

Alex Ratushnyak, Sep 30 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 29    # 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:
        walk(0, -1, 1, 0)    # up
        walk(1, 0, 0, 1)     # right
        walk(0, 1, -1, 0)    # down
        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
    				

A217295 Permutation of natural numbers arising from applying the walk of triangular horizontal-last spiral (defined in A214226) to the data of square spiral (e.g. A214526).

Original entry on oeis.org

1, 5, 6, 7, 22, 8, 2, 4, 16, 36, 17, 18, 19, 20, 21, 44, 75, 45, 23, 9, 11, 3, 15, 35, 63, 99, 64, 37, 38, 39, 40, 41, 42, 43, 74, 113, 160, 114, 76, 46, 24, 10, 28, 12, 14, 34, 62, 98, 142, 194, 143, 100, 65, 66, 67, 68, 69, 70, 71, 72, 73, 112, 159, 214, 277
Offset: 1

Views

Author

Alex Ratushnyak, Sep 30 2012

Keywords

Crossrefs

Programs

  • Python
    SIZE = 29    # 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:
        walk(0, -1, 1, 0)    # up
        walk(1, 0, 0, 1)     # right
        walk(0, 1, -1, 0)    # down
        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 1:
        walk2(1,  1, -1,  0)    # down-right
        walk2(-1, 0,  1, -1)    # left
        walk2(-1, 0,  1, -1)    # left
        if posX<2:
            break
        walk2(1, -1,  1,  1)    # up-right

A220102 Permutation of natural numbers arising from applying the walk of square spiral (e.g. A214526) to the data of double square spiral (defined in A220098).

Original entry on oeis.org

1, 2, 4, 6, 8, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 50, 52, 54, 56
Offset: 1

Views

Author

Alex Ratushnyak, Dec 04 2012

Keywords

Crossrefs

Programs

  • C
    #include 
    #define SIZE 20
    int grid[SIZE][SIZE];
    int direction[] = {0, -1,  1, 0, 0, 1, -1, 0};
    main() {
      int i, j, x1, y1, x2, y2, stepSize;
      int direction1pos=0, direction2pos=4, val;
      x1 = y1 = x2 = y2 = SIZE/2;
      for (val=grid[y1][x1]=1, stepSize=0; ; ++stepSize) {
        if (x1<1 || x1>=SIZE-1 || x2<1 || x2>=SIZE-1) break;
        if (y1<1 || y1>=SIZE-1 || y2<1 || y2>=SIZE-1) break;
        for (i=stepSize|1; i; ++val,--i) {
          x1 += direction[direction1pos  ];
          y1 += direction[direction1pos+1];
          x2 += direction[direction2pos  ];
          y2 += direction[direction2pos+1];
          grid[y1][x1] = val*2;
          grid[y2][x2] = val*2+1;
        }
        direction1pos = (direction1pos+2) & 7;
        direction2pos = (direction2pos+2) & 7;
      }
      direction1pos=0;
      x1 = y1 = SIZE/2;
      for (stepSize=2; ; ++stepSize) {
        for (i=stepSize/2; i; --i) {
          if (grid[y1][x1]==0) return;
          printf("%d, ",grid[y1][x1]);
          x1 += direction[direction1pos  ];
          y1 += direction[direction1pos+1];
        }
        direction1pos = (direction1pos+2) & 7;
      }
    }

A334742 Pascal's spiral: starting with a(1) = 1, proceed in a square spiral, computing each term as the sum of horizontally and vertically adjacent prior terms.

Original entry on oeis.org

1, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 10, 12, 12, 14, 17, 20, 20, 23, 27, 32, 37, 37, 42, 48, 55, 62, 62, 69, 77, 87, 99, 111, 111, 123, 137, 154, 174, 194, 194, 214, 237, 264, 296, 333, 370, 370, 407, 449, 497, 552, 614, 676, 676, 738, 807, 884, 971, 1070
Offset: 1

Views

Author

Alec Jones and Peter Kagey, May 09 2020

Keywords

Comments

This is the square spiral analogy of Pascal's triangle thought of as a table read by antidiagonals.

Examples

			Spiral begins:
  111--99--87--77--69--62
                        |
   12--12--10---8---7  62
    |               |   |
   14   2---2---1   7  55
    |   |       |   |   |
   17   3   1---1   6  48
    |   |           |   |
   20   3---4---5---5  42
    |                   |
   20--23--27--32--37--37
a(15) = 10 = 8 + 2, the sum of the cells immediately to the right and below. The term to the left is not included in the sum because it has not yet occurred in the spiral.
		

Crossrefs

x- and y-coordinates are given by A174344 and A274923, respectively.

Formula

a(A033638(n)) = a(A002620(n)) for n > 1.

A220098 Manhattan distances between 2n and 1 in the double spiral with positive integers and 1 at the center.

Original entry on oeis.org

1, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12, 13
Offset: 1

Views

Author

Alex Ratushnyak, Dec 04 2012

Keywords

Comments

Double spiral begins:
.
82---84---86---88---90---92---94---96---98
|
80 51---53---55---57---59---61---63---65
| | |
78 49 26---28---30---32---34---36 67
| | | | |
76 47 24 11---13---15---17 38 69
| | | | | | |
74 45 22 9 2----4 19 40 71
| | | | | | | | |
72 43 20 7 1 6 21 42 73
| | | | | | | | |
70 41 18 5----3 8 23 44 75
| | | | | | |
68 39 16---14---12---10 25 46 77
| | | | |
66 37---35---33---31---29---27 48 79
| | |
64---62---60---58---56---54---52---50 81
|
99---97---95---93---91---89---87---85---83

Examples

			From _Philippe Deléham_, Mar 08 2013: (Start)
As a square array, this begins:
  1,  1,  2,  2,  3,  3,  4,  4,  5, ...
  2,  3,  3,  4,  4,  5,  5,  6,  6, ...
  2,  4,  5,  5,  6,  6,  7,  7,  8, ...
  3,  4,  6,  7,  7,  8,  8,  9,  9, ...
  3,  5,  6,  8,  9,  9, 10, 10, 11, ...
  4,  5,  7,  8, 10, 11, 11, 12, 12, ...
  4,  6,  7,  9, 10, 12, 13, 13, 14, ...
  5,  6,  8,  9, 11, 12, 14, 15, 15, ..., etc.
As a triangle, this begins:
  1
  2, 1
  2, 3, 2
  3, 4, 3, 2
  3, 4, 5, 4, 3
  4, 5, 6, 5, 4, 3, etc. (End)
		

Crossrefs

Programs

  • C
    #include 
    #define SIZE 20
    int grid[SIZE][SIZE];
    int direction[] = {0, -1,  1, 0, 0, 1, -1, 0};
    main() {
      int i, j, x1, y1, x2, y2, stepSize;
      int direction1pos=0, direction2pos=4, val;
      x1 = y1 = x2 = y2 = SIZE/2;
      for (val=grid[y1][x1]=1, stepSize=0; ; ++stepSize) {
        if (x1<1 || x1>=SIZE-1 || x2<1 || x2>=SIZE-1) break;
        if (y1<1 || y1>=SIZE-1 || y2<1 || y2>=SIZE-1) break;
        for (i=stepSize|1; i; ++val,--i) {
          x1 += direction[direction1pos  ];
          y1 += direction[direction1pos+1];
          x2 += direction[direction2pos  ];
          y2 += direction[direction2pos+1];
          grid[y1][x1] = val*2;
          grid[y2][x2] = val*2+1;
          printf("%d, ",abs(x1-SIZE/2)+abs(y1-SIZE/2));
        }
        direction1pos = (direction1pos+2) & 7;
        direction2pos = (direction2pos+2) & 7;
      }
      for (i=0; i
    				
  • PARI
    step(v, m) = concat(v, vector(m, k, 1+v[#v-k+1]))
    a(max_n) = {my(v=[0], k=1); while(#v < max_n+1, v=step(v,k); k++); v[2..max_n+1]} \\ Thomas Scheuerle, Jan 07 2025
    
  • PARI
    A053615(n) = if(n<1, 0, sqrtint(n) - A053615(n - sqrtint(n)))
    a(n) = A053615(floor( floor( (sqrtint(n*8) + 1)/2 )^2/2 ) + n) \\ Thomas Scheuerle, Jan 07 2025

Formula

abs( a(n) - a(n-1) ) = 1.
From Thomas Scheuerle, Jan 07 2025: (Start)
a(n*(n+1)/2 - k) = 1 + a(n*(n-1)/2 + k) with a(0) = 0 and for 0 <= k < n.
a(n) = A053615(A128217(n+1)). (End)

A232113 a(n) is the Manhattan distance between n and 2*n in a square spiral of positive integers with 1 at the center.

Original entry on oeis.org

1, 2, 3, 2, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 3, 4, 3, 2, 3, 2, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 11, 8, 11, 12, 13, 12, 9, 10, 13, 16, 15, 12, 9, 12, 15, 16, 15, 12, 9, 12, 15, 14, 13, 12, 11, 12, 13, 12, 11, 10, 9, 10, 11, 10, 9, 8, 7, 8, 9
Offset: 1

Views

Author

Alex Ratushnyak, Nov 19 2013

Keywords

Comments

Spiral 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
.
Numbers n such that a(n)^2=n: 1, 4, 16, 625, 20736, 707281, 24010000, 815730721, ...; that is, 1, 4, 2^4, 5^4, 12^4, 29^4, 70^4, 169^4, ... (cf. Pell numbers: A000129).

Crossrefs

A232114 a(n) is the Manhattan distance between n and n^2 in a square spiral of positive integers with 1 at the center.

Original entry on oeis.org

0, 2, 2, 2, 6, 4, 6, 8, 6, 12, 8, 12, 12, 12, 16, 12, 20, 14, 20, 18, 20, 22, 20, 26, 20, 30, 22, 30, 26, 30, 30, 30, 34, 30, 38, 30, 42, 32, 42, 36, 42, 40, 42, 44, 42, 48, 42, 52, 42, 56, 44, 56, 48, 56, 52, 56, 56, 56, 60, 56, 64, 56, 68, 56, 72, 58, 72, 62, 72, 66
Offset: 1

Views

Author

Alex Ratushnyak, Nov 19 2013

Keywords

Comments

Spiral 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
.
Numbers n such that a(n)=n: 2, 8, 12, 22, 30, 44, 56, 74, 90, 112, 132, 158, 182, 212, 240, 274, 306, 344, 380, 422, ... That is, 2 * A084263.

Crossrefs

A366353 a(0) = 0; for n > 0, a(n) is the largest taxicab distance on a square spiral between a(n-1) and any previous occurrence of a(n-1). If a(n-1) has not previously occurred then a(n) = 0.

Original entry on oeis.org

0, 0, 1, 0, 2, 0, 2, 2, 3, 0, 4, 0, 4, 2, 5, 0, 6, 0, 6, 2, 6, 4, 7, 0, 6, 8, 0, 7, 5, 4, 8, 5, 3, 4, 6, 8, 10, 0, 9, 0, 7, 7, 8, 12, 0, 7, 6, 8, 10, 12, 6, 10, 11, 0, 9, 8, 13, 0, 11, 6, 9, 6, 11, 10, 13, 8, 12, 13, 11, 10, 9, 12, 8, 15, 0, 13, 13, 12, 11, 12, 13, 16, 0, 13, 15, 11, 11, 10, 12
Offset: 0

Views

Author

Scott R. Shannon, Oct 08 2023

Keywords

Examples

			The spiral begins:
.
                                .
    10--8---6---4---3---5---8   :
    |                       |   :
    0   6---0---5---2---4   4   9
    |   |               |   |   |
    9   0   2---0---1   0   5   0
    |   |   |       |   |   |   |
    0   6   0   0---0   4   7   11
    |   |   |           |   |   |
    7   2   2---2---3---0   0   10
    |   |                   |   |
    7   6---4---7---0---6---8   6
    |                           |
    8---12--0---7---6---8---10--12
.
a(2) = 1 as the taxicab distance between a(1) = 0, at (1,0) relative to the starting square, and the only previous occurrence of 0, a(0) at (0,0), is 1.
a(8) = 3 as the maximum taxicab distance between a(7) = 2, at (0,-1) relative to the starting square, and any previous occurrence of 2 is 3, to a(4) = 2 at (-1,1) relative to the starting square.
a(32) = 3 as the maximum taxicab distance between a(31) = 5, at (2,3) relative to the starting square, and any previous occurrence of 5 is 3, to a(28) = 5 at (3,1) relative to the starting square, and also to a(14) = 5 at (0,2) relative to the starting square. This is the first term to differ from A366354.
		

Crossrefs

A366354 a(0) = 0; for n > 0, a(n) is the largest taxicab distance on a square spiral between any two previous occurrences of a(n-1). If a(n-1) has not previously occurred then a(n) = 0.

Original entry on oeis.org

0, 0, 1, 0, 2, 0, 2, 2, 3, 0, 4, 0, 4, 2, 5, 0, 6, 0, 6, 2, 6, 4, 7, 0, 6, 8, 0, 7, 5, 4, 8, 5, 4, 8, 8, 9, 0, 10, 0, 10, 2, 7, 8, 12, 0, 10, 8, 12, 4, 8, 12, 7, 8, 12, 10, 9, 6, 12, 12, 12, 12, 12, 12, 12, 13, 0, 11, 0, 11, 2, 8, 12, 14, 0, 11, 8, 12, 14, 5, 8, 12, 15, 0, 15, 2, 9, 10, 9, 10, 11
Offset: 0

Views

Author

Scott R. Shannon, Oct 08 2023

Keywords

Examples

			The spiral begins:
.
                                .
    0---9---8---8---4---5---8   :
    |                       |   :
   10   6---0---5---2---4   4   10
    |   |               |   |   |
    0   0   2---0---1   0   5   12
    |   |   |       |   |   |   |
   10   6   0   0---0   4   7   8
    |   |   |           |   |   |
    2   2   2---2---3---0   0   7
    |   |                   |   |
    7   6---4---7---0---6---8   12
    |                           |
    8--12---0--10---8--12---4---8
.
a(2) = 1 as the maximum taxicab distance between 0 = a(1) and the only previous occurrence of 0, a(0) at (0,0), is 1.
a(8) = 3 as the maximum taxicab distance between any two previous occurrences of 2 = a(7) is 3, between a(3) = 2, at (-1,1) relative to the starting square, and a(7) = 2 at (0,-1) relative to the starting square.
a(32) = 4 as the maximum taxicab distance between any two previous occurrences of 5 = a(31) is 4, between a(14) = 5, at (0,2) relative to the starting square, and a(28) = 5 at (3,1) relative to the starting square. This is the first term to differ from A366353.
		

Crossrefs

A232115 a(n) is the Manhattan distance between n and n(n+1)/2 in a square spiral of positive integers with 1 at the center.

Original entry on oeis.org

0, 1, 3, 4, 2, 3, 5, 6, 4, 5, 9, 6, 6, 7, 11, 8, 8, 15, 9, 10, 10, 13, 11, 12, 22, 11, 15, 18, 12, 15, 17, 22, 12, 21, 25, 10, 26, 21, 19, 18, 24, 27, 15, 34, 24, 21, 31, 20, 28, 21, 31, 24, 28, 41, 19, 36, 36, 23, 35, 26, 38, 23, 41, 36, 28, 53, 29, 38, 40, 31, 39
Offset: 1

Views

Author

Alex Ratushnyak, Nov 19 2013

Keywords

Comments

Spiral 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
.
Numbers n such that a(n)*2=n: 2, 6, 10, 12, 14, 16, 20, 24, 30, 80, 192, 198, 350, 524, 536, 548, 552, 560, 564, 576, 588, 594, 606, 618, 630, 1380, 1900, 4446, ...

Crossrefs

Programs

  • Python
    import math
    def get_x_y(n):
      sr = math.isqrt(n-1)
      sr = sr-1+(sr&1)
      rm = n-sr*sr
      d = (sr+1)//2
      if rm<=sr+1:
         return -d+rm,d
      if rm<=sr*2+2:
         return d,d-(rm-(sr+1))
      if rm<=sr*3+3:
         return d-(rm-(sr*2+2)),-d
      return -d,-d+rm-(sr*3+3)
    for n in range(1,333):
      x0,y0 = get_x_y(n)
      x1,y1 = get_x_y(n*(n+1)//2)
      print(abs(x1-x0)+abs(y1-y0), end=', ')
Previous Showing 11-20 of 26 results. Next