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 31-40 of 68 results. Next

A328894 a(n) is the number of steps before being trapped for a knight starting on square n on a single-digit square-spiral numbered board and where the knight moves to the smallest numbered unvisited square; the minimum distance from the origin is used if the square numbers are equal; the smallest spiral number ordering is used if the distances are equal.

Original entry on oeis.org

1069, 884, 995, 884, 885, 988, 885, 943, 549, 1070, 942, 548, 881, 951, 987, 886, 661, 601, 1123, 1313, 1034, 1070, 1101, 1070, 1930, 943, 655, 882, 1930, 943, 1471, 992, 583, 884, 806, 704, 1062, 1098, 1096, 1129, 1174, 723, 438, 1102, 854
Offset: 1

Views

Author

Scott R. Shannon, Oct 29 2019

Keywords

Comments

This is the number of completed steps before being trapped for a knight starting on a square with square spiral number n for a knight with step rules given in A326918. We use the standard square spiral number of A316667 to define the start square, as opposed to its single-digit board value, as it is a unique value for each square on the board.
Unlike board numbering methods which have a unique smallest value at the origin, which causes the knight to immediately move toward it when starting from any other square, the single-digit numbering method has multiple small values distributed over the board. Therefore when starting from an arbitrary square the knight may move in any direction, toward the smallest valued neighboring square one knight leap away. Only when two or more such squares exist with the same number does the origin start to act as the square of attraction. This means some knight paths will meander well away from the origin and can become trapped before ever approaching it.
For starting squares n from 1 to 10^6 the longest path before being trapped is a(435525) = 2865. The smallest path to being trapped is a(42329) = 109. The path which ends on the square with the largest standard square spiral number is a(31223), which ends on square 47863. The first path which ends on the square with the smallest standard spiral number is a(138), which ends on square 4. This square is adjacent to the origin, but it is curious that the three squares with smaller spiral numbers, 1,2,3, do not act as the end square for any of the starting squares studied.

Examples

			a(1) = 1069. See A326918.
The squares are numbered using single digits of the spiral number ordering as:
                                .
                                .
    2---2---2---1---2---0---2   2
    |                       |   |
    3   1---2---1---1---1   9   3
    |   |               |   |   |
    2   3   4---3---2   0   1   1
    |   |   |       |   |   |   |
    4   1   5   0---1   1   8   3
    |   |   |           |   |   |
    2   4   6---7---8---9   1   0
    |   |                   |   |
    5   1---5---1---6---1---7   3
    |                           |
    2---6---2---7---2---8---2---9
If the knight has a choice of two or more squares in this spiral with the same number which also have the same distance from the origin, then the square with the minimum standard spiral number, as shown in A316667, is chosen.
		

Crossrefs

A335856 Squares visited by a chess king on a spirally numbered infinite board where the king moves to the adjacent unvisited square containing the lowest prime number. If no such square is available it chooses the lowest-numbered adjacent unvisited square.

Original entry on oeis.org

1, 2, 3, 11, 29, 13, 31, 59, 32, 14, 4, 5, 17, 37, 67, 103, 149, 104, 66, 38, 18, 19, 7, 23, 47, 79, 48, 24, 8, 6, 20, 41, 71, 43, 73, 109, 72, 42, 21, 22, 44, 45, 46, 76, 75, 113, 74, 112, 110, 111, 157, 211, 271, 209, 269, 337, 267, 205, 151, 107, 69, 39, 40, 68, 105, 106, 70, 108
Offset: 1

Views

Author

Scott R. Shannon, Jun 27 2020

Keywords

Comments

This sequences gives the numbers of the squares visited by a chess king moving on a square-spiral numbered board where the king starts on the 1 numbered square and at each step moves to the adjacent unvisited square containing the lowest prime number. If no adjacent unvisited square contains a prime number then the square with the lowest spiral number is chosen. Note that if the king simply moves to the lowest unvisited number the sequence will be infinite as the king will just follow the square spiral path.
The sequence is finite. After 719 steps the square with number 437 is visited, after which all adjacent neighboring squares have been visited.
Of the 719 visited squares 165 contain prime numbers while 554 contain composites. As the odd numbers are diagonally adjacent in the square spiral the king's path will contain many diagonal steps, often taking numerous diagonal steps is succession - see the attached link image.
The largest visited square is a(709) = 1367. The lowest unvisited square is 33.
The 719 steps until self-trapping occurs are significantly larger than the expected average of 210 moves to self-trapping for a random walk of the king on an infinite chessboard. See the link to the probability density graphs in A323562. - Hugo Pfoertner, Jul 19 2020
When the grid points are labeled starting with 0 at the origin, the king gets trapped after 171 moves at (3,0), after going as far as (10,-11) to the south-east and (-8,7) and (-5,8) to the north-east, see A383183. - M. F. Hasler, May 13 2025

Examples

			The board is numbered with the square spiral:
.
  17--16--15--14--13   .
   |               |   .
  18   5---4---3  12   29
   |   |       |   |   |
  19   6   1---2  11   28
   |   |           |   |
  20   7---8---9--10   27
   |                   |
  21--22--23--24--25--26
.
a(1) = 1, the starting square for the king.
a(2) = 2. The four unvisited squares around a(1) the king can move which contain prime numbers are 2,3,5,7. Of those 2 is the lowest.
a(4) = 11. The two unvisited squares around a(3) = 3 the king can move to which contain prime numbers are 11 and 13. Of those 11 is the lowest.
a(9) = 32. There are no unvisited squares around a(8) = 59 which contain prime numbers. The seven other unvisited squares are numbered 32,33,58,60,93,94,95. Of those 32 is the lowest.
		

Crossrefs

Cf. A000040 (the primes), A010051 (characteristic function of the primes).

Programs

  • Python
    from sympy import isprime # or use A010051
    def square_number(z): return int(4*y**2-y-x if (y := z.imag) >= abs(x := z.real)
        else 4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else (4*x-3)*x+y)
    def A335856(n, moves=(1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j)):
        if not hasattr(A:=A335856, 'terms'): A.terms=[1]; A.pos=0
        while len(A.terms) < n:
            try: move = min((1-isprime(s), s, z) for d in moves if
                            (s := square_number(z := A.pos+d)+1)not in A.terms)
            except ValueError:
                raise IndexError(f"Sequence has only {len(A.terms)} terms")
            A.terms.append(move[1]); A.pos = move[2]
        return A.terms[n-1]
    A335856(999) # gives IndexError: Sequence has only 720 terms
    A335856.terms # shows all 720 terms; append [:N] to see only N terms
    # M. F. Hasler, May 13 2025

Extensions

Name edited by Peter Munn, May 11 2025
More terms (complete sequence) from M. F. Hasler, May 13 2025

A341327 The spiral numbers not covered by any square in the square spiral tiling of A341160.

Original entry on oeis.org

6, 19, 28, 29, 53, 54, 61, 62, 63, 86, 87, 114, 115, 116, 117, 161, 162, 163, 164, 185, 186, 187, 188, 189, 227, 228, 229, 230, 231, 232, 244, 245, 246, 247, 248, 311, 312, 313, 314, 315, 407, 408, 409, 410, 411, 412, 413, 771, 772, 773, 774, 775, 776, 777, 778, 779, 866, 867, 868, 869, 870, 871
Offset: 1

Views

Author

Scott R. Shannon, Feb 09 2021

Keywords

Comments

See A341160 for an image of the square spiral tiling which shows the uncovered numbers in black.

Examples

			a(1) = 6 and a(2) = 19 as the first, third, fourth, and seventh square of A341160 cover the numbers (1), (5,18), (7,20), (40) respectively which leaves a gap containing numbers 6 and 19 which cannot be covered by any subsequence square.
		

Crossrefs

A329972 Y-coordinate of a point moving in a triangular spiral.

Original entry on oeis.org

0, 0, 1, 0, -1, -1, -1, -1, -1, -1, 0, 1, 2, 1, 0, -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4
Offset: 0

Views

Author

Mikk Heidemaa, Nov 26 2019

Keywords

Comments

A329116 gives x-coordinates for a point moving in counterclockwise triangular spiral.

Examples

			    y
     |
   4 |                         56
     |                           \
     |                            \
     |                             \
   3 |                         30  55
     |                         / \   \
     |                        /   \   \
     |                       /     \   \
   2 |                     31  12  29  54
     |                     /   / \   \   \
     |                    /   /   \   \   \
     |                   /   /     \   \   \
   1 |                 32  13   2  11  28  53
     |                 /   /   / \   \   \   \
     |                /   /   /   \   \   \   \
     |               /   /   /     \   \   \   \
   0 |             33  14   3   0---1  10  27  52
     |             /   /   /             \   \   \
     |            /   /   /               \   \   \
     |           /   /   /                 \   \   \
  -1 |         34  15   4---5---6---7---8---9  26  51
     |         /   /                             \   \
     |        /   /                               \   \
     |       /   /                                 \   \
  -2 |     35  16--17--18--19--20--21--22--23--24--25  50
     |     /                                             \
     |    /                                               \
     |   /                                                 \
  -3 | 36--37--38--39--40--41--42--43--44--45--46--47--48--49
     |
     +--------------------------------------------------------
   x:  -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6   7
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Table[Floor[Min[#*Max[0, 2*Mod[#, 2] - 2], -2*#*Mod[#, -1]] + Ceiling[-#/2]] &[Sqrt@ k], {k, 0, n}]; a[64]

Formula

a(n) = floor(min(s*max(((0, 2*s) mod 2) - 2), (-2*s*s) mod (-1)) + ceiling(-s/2)) where s=sqrt(n).

A351043 Lexicographically earliest non-extendable Racetrack trajectory (using von Neumann neighborhood) on spiral on infinite square grid.

Original entry on oeis.org

0, 1, 9, 24, 46, 45, 21, 6, 4, 15, 33, 32, 12, 11, 10, 8, 7, 5, 16, 36, 63, 97, 96, 60, 13, 27, 50, 80, 119, 165, 164, 116, 75, 41, 68, 66, 64, 99, 141, 140, 138, 93, 55, 86, 84, 49, 79, 78, 76, 43, 69, 104, 102, 100, 143, 193, 192, 190, 137, 57, 54, 52, 25
Offset: 0

Views

Author

Pontus von Brömssen, Jan 30 2022

Keywords

Comments

The car starts at square 0 and thereafter moves, according to the rules of Racetrack with von Neumann neighborhood (see A351042), to the lowest numbered unvisited square. The spiral numbering is described in A316328. After 146 steps, the car cannot move to any unvisited square, so the sequence is finite with 147 terms.
The position of the car after n steps is (A174344(a(n)+1), A274923(a(n)+1)). - Pontus von Brömssen, Jan 30 2025

Crossrefs

A358278 Squares visited by a knight moving on a square-spiral numbered board where the knight moves to the smallest numbered unvisited square and where the square is on a different square ring of numbers than the current square.

Original entry on oeis.org

1, 10, 3, 16, 33, 4, 11, 8, 19, 38, 5, 14, 29, 2, 13, 28, 9, 12, 27, 24, 7, 18, 35, 60, 15, 6, 17, 34, 59, 30, 53, 26, 79, 46, 21, 40, 67, 36, 61, 32, 55, 86, 51, 48, 23, 44, 71, 20, 39, 66, 99, 62, 37, 68, 41, 22, 43, 70, 105, 148, 65, 98, 139, 94, 31, 54, 85, 50, 25, 52, 49, 78, 45, 74
Offset: 1

Views

Author

Scott R. Shannon and Eric Angelini, Nov 08 2022

Keywords

Comments

This sequence is finite: after 1455 squares have been visited the square with number 1345 is reached after which all eight neighboring squares the knight could move to have already been visited. See the linked image. The largest visited square is a(1374) = 1996 while the smallest unvisited square is 1024.

Examples

			The board is numbered using a square spiral. The square rings of numbers are shown below:
.
    17--16--15--14--13   .
     |               |   .
    18   5---4---3  12  29
     |   |       |   |   |
    19   6   1   2  11  28
     |   |       |   |   |
    20   7---8---9  10  27
     |               |   |
    21--22--23--24--25  26
                         |
   -44--45--46--47--48--49
.
a(4) = 16 as after the knight moves to the square containing a(3) = 3 the available unvisited squares are 6, 8, 16, 28, 30, 32, 34. Of these 6 and 8 are the smallest but both of them lie on the first square ring of numbers, the same as the current number 3. Of the remaining squares the smallest unvisited square is 16. This is the first term to differ from A316667.
		

Crossrefs

A308412 Indices of Gaussian primes on a square spiral.

Original entry on oeis.org

3, 5, 7, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 52, 54, 60, 62, 68, 70, 76, 78, 82, 84, 88, 90, 92, 94, 98, 100, 102, 104, 108, 110, 112, 114, 118, 120, 122, 126, 128, 132, 134, 138, 140, 144, 146, 150, 152, 156, 158
Offset: 1

Views

Author

Rémy Sigrist, Jun 01 2019

Keywords

Comments

These are the numbers k > 0 such that A174344(k) + i*A274923(k) is a Gaussian prime (where i denotes the imaginary unit).
For symmetry reasons, we obtain the same sequence when considering a clockwise or a counterclockwise square spiral, or when initially moving towards any unit direction.
All terms except the first four are even.

Examples

			The first terms displayed on the center of a counterclockwise square spiral are:
  y\x|    -5   -4   -3   -2   -1    0   +1   +2   +3   +4   +5
  ---+--------------------------------------------------------
   +5|     *--100----*---98----*----*----*---94----*---92----*
     |     |                                                 |
   +4|   102    *----*----*---62----*---60----*----*----*   90
     |     |    |                                       |    |
   +3|     *    *    *---36----*---34----*---32----*    *    *
     |     |    |    |                             |    |    |
   +2|   104    *   38    *---16----*---14----*   30    *   88
     |     |    |    |    |                   |    |    |    |
   +1|     *   68    *   18    5----*----3   12    *   54    *
     |     |    |    |    |    |         |    |    |    |    |
    0|     *    *   40    *    *    *----*    *   28    *    *
     |     |    |    |    |    |              |    |    |    |
   -1|     *   70    *   20    7----*----9---10    *   52    *
     |     |    |    |    |                        |    |    |
   -2|   108    *   42    *---22----*---24----*---26    *   84
     |     |    |    |                                  |    |
   -3|     *    *    *---44----*---46----*---48----*----*    *
     |     |    |                                            |
    4|   110    *----*----*---76----*---78----*----*----*---82
     |     |
    5|     *--112----*--114----*----*----*--118----*--120----*
		

Crossrefs

Programs

  • Maple
    SP:= proc(n) option remember; local k;
    k:=floor(sqrt(4*n-7)) mod 4;
    procname(n-1) -I*exp(I*k*Pi/2)
    end proc:
    SP(1):= 0:
    select(i -> GaussInt:-GIprime(SP(i)), [$1..1000]); # Robert Israel, May 20 2024
  • PARI
    \\ See Links section.

A333825 Lexicographically earliest sequence of distinct positive integers, which when mapped onto a square spiral, gives a set without three distinct aligned points.

Original entry on oeis.org

1, 2, 3, 4, 17, 20, 22, 27, 45, 48, 67, 79, 80, 131, 135, 174, 180, 194, 201, 209, 236, 254, 312, 319, 394, 523, 644, 656, 706, 711, 733, 765, 766, 845, 848, 921, 922, 935, 1034, 1051, 1219, 1292, 1310, 1330, 1399, 1410, 1546, 1589, 1674, 1792, 1816, 1863
Offset: 1

Views

Author

Rémy Sigrist, Apr 07 2020

Keywords

Comments

This sequence has similarities with A236266.

Examples

			The first terms, mapped onto a square spiral, are:
         *---*---*---*---*---*---*---*---*
         |                               |
         *   *---*---*---*---*---*---*   *
         |   |                       |   |
        67   *  17---*---*---*---*   *   *
         |   |   |               |   |   |
         *   *   *   *---4---3   *   *   *
         |   |   |   |       |   |   |   |
         *   *   *   *   1---2   *   *   *
         |   |   |   |           |   |   |
         *   *  20   *---*---*---*  27   *
         |   |   |                   |   |
         *   *   *--22---*---*---*---*   *
         |   |                           |
         *   *---*--45---*---*--48---*---*
         |
         *---*---*---*---*---*--79--80---*
		

Crossrefs

See A333835 and A333866 for a similar sequences.

A334741 Fill an infinite square array by following a spiral around the origin; in the central cell enter a(0)=1; thereafter, in the n-th cell, enter the sum of the entries of those earlier cells that are in the same row or column as that cell.

Original entry on oeis.org

1, 1, 1, 2, 3, 5, 8, 11, 21, 40, 47, 93, 180, 203, 397, 796, 1576, 1675, 3305, 6636, 13192, 14004, 27607, 55029, 110192, 220024, 226740, 450123, 898661, 1798700, 3594248, 3704800, 7354303, 14681369, 29349536, 58710640, 117394896, 119196748, 237492079
Offset: 0

Views

Author

Alec Jones and Peter Kagey, May 09 2020

Keywords

Comments

The spiral track being used here is the same as in A274640, except that the starting cell here is indexed 0 (as in A274641).
The central cell gets index 0 (and we fill it in with the value a(0)=1).

Examples

			Spiral begins:
     3----2----1
     |         |
     5    1----1   47
     |              |
     8---11---21---40
a(11) = 47 = 1 + 1 + 5 + 40, the sum of the cells in its row and column.
		

Crossrefs

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

Programs

  • PARI
    \\ here P(n) returns A174344 and A274923 as pair.
    P(n)={my(m=sqrtint(n), k=ceil(m/2)); n -= 4*k^2; if(n<0, if(n<-m, [k, 3*k+n], [-k-n, k]), if(nAndrew Howroyd, May 09 2020

A340172 List of Y-coordinates of point moving along one of the arms of a counterclockwise double square spiral; A340171 gives X-coordinates.

Original entry on oeis.org

0, 0, 1, 1, 1, 1, 0, -1, -2, -2, -2, -2, -2, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -6, -6, -6
Offset: 0

Views

Author

Rémy Sigrist, Dec 30 2020

Keywords

Comments

The odd function f such that f(n) = (A340171(n), a(n)) for any n >= 0 will visit exactly once every lattice point (so it is a bijection from Z to Z^2).

Examples

			The spiral starts as follows:
      +-----+-----+-----+-----+-----+
      .                             |
      .                             |
      .     +-----+-----+-----+     +
      .     |5     4     3    |2    |
      .     |                 |     |
            +     +-----+-----+     +
            |6    |      0     1    |     .
            |     |                 |     .
            +     +-----+-----+-----+     .
            |7                            .
            |                             .
            +-----+-----+-----+-----+-----+
             8     9     10    11    12    13
- so a(0) = a(1) = a(6) = 0,
-    a(2) = a(3) = a(4) = a(5) = 1.
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

abs(a(n+1)-a(n)) + abs(A340171(n+1)-A340171(n)) = 1.
a(n) = A340171(n) iff n belongs to A001105.
a(n) = - A340171(n) iff n belongs to A046092.
2*a(n) = A340171(n) iff n belongs to A139274.
a(n) = 2*A340171(n) iff n belongs to A139275.
a(n) * A340171(n) = 0 iff n belongs to A000217.
a(n) = 0 iff n belongs to A000384.
Previous Showing 31-40 of 68 results. Next