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-6 of 6 results.

A275609 Square spiral in which each new term is the least nonnegative integer distinct from its (already assigned) eight neighbors.

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Nov 14 2016

Keywords

Comments

"Neighbor" here means the eight cells surrounding a cell (cells that are a chess king's move away). The number assigned to a cell is the mex of the numbers that have already been assigned to any of its eight neighbors. - N. J. A. Sloane, Mar 24 2019
The largest element is 4 and it is also the element with lower density in the spiral.
[Proof that 4 is the largest term. When the spiral is being filled in, the maximal number of its neighbors that have already been filled in is four. The mex of four nonnegative numbers is at most 4. QED - N. J. A. Sloane, Mar 24 2019]
For more information see also A307188. - Omar E. Pol, Apr 01 2019

Examples

			Illustration of initial terms as a spiral (n = 0..168):
.
.     1 - 2 - 1 - 0 - 4 - 0 - 2 - 0 - 1 - 3 - 1 - 3 - 1
.     |                                               |
.     3   0 - 3 - 2 - 1 - 3 - 1 - 3 - 2 - 0 - 2 - 0   2
.     |   |                                       |   |
.     1   2   1 - 0 - 4 - 0 - 2 - 0 - 1 - 3 - 1   3   1
.     |   |   |                               |   |   |
.     0   4   3   2 - 1 - 3 - 1 - 3 - 2 - 0   2   0   2
.     |   |   |   |                       |   |   |   |
.     3   1   0   4   0 - 2 - 0 - 4 - 1   3   1   3   1
.     |   |   |   |   |               |   |   |   |   |
.     0   2   3   1   3   1 - 3 - 2   0   2   0   2   0
.     |   |   |   |   |   |       |   |   |   |   |   |
.     3   1   0   2   0   2   0 - 1   3   1   3   1   3
.     |   |   |   |   |   |           |   |   |   |   |
.     0   2   3   1   3   1 - 3 - 2 - 0   2   0   2   0
.     |   |   |   |   |                   |   |   |   |
.     3   1   0   2   0 - 2 - 0 - 1 - 3 - 1   3   1   3
.     |   |   |   |                           |   |   |
.     0   2   3   1 - 3 - 1 - 3 - 2 - 0 - 2 - 0   2   0
.     |   |   |                                   |   |
.     3   1   0 - 2 - 0 - 2 - 0 - 1 - 3 - 1 - 3 - 1   3
.     |   |                                           |
.     0   2 - 3 - 1 - 3 - 1 - 3 - 2 - 0 - 2 - 0 - 2 - 0
.     |
.     1 - 4 - 0 - 2 - 0 - 2 - 0 - 1 - 3 - 1 - 3 - 1 - 3
.
a(13) = 4 is the first "4" in the sequence and its four neighbors are 3 (southwest), 2 (south), 0 (southeast) and 1 (east) when a(13) is placed in the spiral.
a(157) = 4 is the 6th "4" in the sequence and it is also the first "4" that is below the NE-SW main diagonal of the spiral (see the second term in the last row of the above diagram).
		

Crossrefs

Cf. A274912, A274917, A274920, A275606, A278354 (number of neighbors).
See A307188-A307192 for the positions of 0,1,2,3,4 respectively.
The eight spokes starting at the origin are A307193 - A307200.

Programs

  • Maple
    fx:= proc(n) option remember; `if`(n=1, 0, (k->
           fx(n-1)+sin(k*Pi/2))(floor(sqrt(4*(n-2)+1)) mod 4))
         end:
    fy:= proc(n) option remember; `if`(n=1, 0, (k->
           fy(n-1)-cos(k*Pi/2))(floor(sqrt(4*(n-2)+1)) mod 4))
         end:
    b:= proc() -1 end:
    a:= proc(n) option remember; local x, y, s, m;
          x, y:= fx(n+1), fy(n+1);
          if n>0 then a(n-1) fi;
          if b(x, y) >= 0 then b(x, y)
        else s:= {b(x+1, y+1), b(x-1, y-1), b(x+1, y-1), b(x-1, y+1),
                  b(x+1, y  ), b(x-1, y  ), b(x  , y+1), b(x  , y-1)};
             for m from 0 while m in s do od;
             b(x, y):= m
          fi
        end:
    seq(a(n), n=0..120);  # Alois P. Heinz, Mar 29 2019
  • Mathematica
    fx[n_] := fx[n] = If[n == 1, 0, Function[k, fx[n - 1] + Sin[k*Pi/2]][Mod[ Floor[Sqrt[4*(n - 2) + 1]], 4]]];
    fy[n_] := fy[n] = If[n == 1, 0, Function[k, fy[n - 1] - Cos[k*Pi/2]][Mod[ Floor[Sqrt[4*(n - 2) + 1]], 4]]];
    b[, ] := -1;
    a[n_] := a[n] = Module[{x, y, s, m}, {x, y} = {fx[n + 1], fy[n + 1]}; If[n > 0, a[n - 1]]; If [b[x, y] >= 0, b[x, y], s = {b[x + 1, y + 1], b[x - 1, y - 1], b[x + 1, y - 1], b[x - 1, y + 1], b[x + 1, y], b[x - 1, y], b[x, y + 1], b[x, y - 1]}; For[m = 0, MemberQ[s, m], m++]; b[x, y] = m]];
    a /@ Range[0, 120] (* Jean-François Alcover, Feb 25 2020, after Alois P. Heinz *)

Formula

a(n) = A274917(n) - 1.

A278317 Number of neighbors of each new term in a right triangle read by rows.

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Nov 18 2016

Keywords

Comments

To evaluate T(n,k) consider only the neighbors of T(n,k) that are present in the triangle when T(n,k) should be a new term in the triangle.
Apart from the first column and the first two diagonals the rest of the elements are 4's.
For the same idea but for an isosceles triangle see A275015; for a square array see A278290, for a square spiral see A278354; and for a hexagonal spiral see A047931.

Examples

			Triangle begins:
0;
1, 2;
2, 3, 2;
2, 4, 3, 2;
2, 4, 4, 3, 2;
2, 4, 4, 4, 3, 2;
2, 4, 4, 4, 4, 3, 2;
2, 4, 4, 4, 4, 4, 3, 2;
2, 4, 4, 4, 4, 4, 4, 3, 2;
2, 4, 4, 4, 4, 4, 4, 4, 3, 2;
...
		

Crossrefs

Apart from the initial zero, row sums give A004767.
Column 1 is A130130.
Columns > 1 give the terms greater than 1 of A158411.
Right border gives 0 together with A007395, also twice A057427.
Second right border gives A122553.

A275015 Number of neighbors of each new term in an isosceles triangle read by rows.

Original entry on oeis.org

0, 1, 2, 1, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2
Offset: 1

Views

Author

Omar E. Pol, Nov 20 2016

Keywords

Comments

To evaluate a(n) consider only the neighbors of a(n) that are present in the isosceles triangle when a(n) should be a new term in the triangle.
Apart from the left border and the right border, the rest of the elements are 3's.
If every "3" is replaced with a "4", we have the sequence A278290.
a(n) is also the number of new penny-penny contacts when putting pennies in a triangular arrangement.
For the same idea but for a right triangle see A278317; for a square array see A278290, for a square spiral see A278354; and for a hexagonal spiral see A047931.

Examples

			The sequence written as an isosceles triangle begins:
.
.                     0;
.                   1,  2;
.                 1,  3,  2;
.               1,  3,  3,  2;
.             1,  3,  3,  3,  2;
.           1,  3,  3,  3,  3,  2;
.         1,  3,  3,  3,  3,  3,  2;
.       1,  3,  3,  3,  3,  3,  3,  2;
.     1,  3,  3,  3,  3,  3,  3,  3,  2;
.   1,  3,  3,  3,  3,  3,  3,  3,  3,  2;
...
		

Crossrefs

Row sums give A008585.
Left border gives A057427.
Every diagonal that is parallel to the left border gives the elements greater than 1 of A158799.
Right border gives 0 together with A007395, also twice A057427.
Every diagonal that is parallel to the right border gives A122553.

Programs

  • Mathematica
    Table[Boole[n > 1] (Prepend[Reverse@ Rest@ #, First@ #] &@ Range@ n /. k_ /; k > 3 -> 3), {n, 13}] // Flatten (* or *)
    Table[Boole[n > 1] (Map[Mod[#, n] &, Range@ n] /. {k_ /; k > 1 -> 3, 0 -> 2}), {n, 13}] // Flatten (* Michael De Vlieger, Nov 23 2016 *)

A278290 Number of neighbors of each new term in a square array read by antidiagonals.

Original entry on oeis.org

0, 1, 2, 1, 4, 2, 1, 4, 4, 2, 1, 4, 4, 4, 2, 1, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2
Offset: 1

Views

Author

Omar E. Pol, Nov 16 2016

Keywords

Comments

Here the "neighbors" of T(n,k) are defined to be the adjacent elements to T(n,k), in the same row, column or diagonals, that are present in the square array when T(n,k) is the new element of the sequence in progress.
Apart from row 1 and column 1 the rest of the elements are 4's.
If every "4" is replaced with a "3" we have the sequence A275015.
For the same idea but for a right triangle see A278317; for an isosceles triangle see A275015; for a square spiral see A278354; and for a hexagonal spiral see A047931.

Examples

			The corner of the square array read by antidiagonals upwards begins:
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,...
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,...
1, 4, 4, 4, 4, 4, 4, 4, 4, 4,...
1, 4, 4, 4, 4, 4, 4, 4, 4,...
1, 4, 4, 4, 4, 4, 4, 4,...
1, 4, 4, 4, 4, 4, 4,...
1, 4, 4, 4, 4, 4,...
1, 4, 4, 4, 4,...
1, 4, 4, 4,...
1, 4, 4,...
1, 4,...
1,...
..
		

Crossrefs

Antidiagonal sums give 0 together with A004767.
Row 1 gives 0 together with A007395, also twice A057427.
Column 1 gives A057427.

Programs

  • Mathematica
    Table[Boole[# > 1] + 2 Boole[k > 1] + Boole[And[# > 1, k > 1]] &[n - k + 1], {n, 14}, {k, n}] // Flatten (* or *)
    Table[Boole[n > 1] (Map[Mod[#, n] &, Range@ n] /. {k_ /; k > 1 -> 4, 0 -> 2}), {n, 14}] // Flatten (* Michael De Vlieger, Nov 23 2016 *)

A280026 Fill an infinite square array by following a spiral around the origin; in the n-th cell, enter the number of earlier cells that can be seen from that cell.

Original entry on oeis.org

0, 1, 2, 3, 3, 4, 4, 5, 6, 5, 6, 7, 6, 7, 8, 9, 7, 8, 9, 10, 8, 9, 10, 11, 12, 9, 10, 11, 12, 13, 10, 11, 12, 13, 14, 15, 11, 12, 13, 14, 15, 16, 12, 13, 14, 15, 16, 17, 18, 13, 14, 15, 16, 17, 18, 19, 14, 15, 16, 17, 18, 19, 20, 21, 15, 16, 17, 18, 19, 20, 21
Offset: 0

Views

Author

N. J. A. Sloane, Dec 24 2016

Keywords

Comments

The spiral track being used here is the same as in A274640, except that the starting cell here is numbered 0 (as in A274641).
"Can be seen from" means "are on the same row, column, diagonal, or antidiagonal as".
The entry in a cell gives the number of earlier cells that are occupied in any of the eight cardinal directions. - Robert G. Wilson v, Dec 25 2016
First occurrence of k = 0,1,2,3,...: 0, 1, 2, 3, 5, 7, 8, 11, 14, 15, 19, 23, 24, 29, 34, 35, 41, 47, 48, 55, 62, ... - Robert G. Wilson v, Dec 25 2016

Examples

			The central portion of the spiral is:
.
    7---9---8---7---6
    |               |
    8   3---3---2   7
    |   |       |   |
    9   4   0---1   6
    |   |           |
   10   4---5---6---5
    |
    8---9--10--11--12 ...
		

Crossrefs

See A280027 for an additive version.
See A279211, A279212 for versions that follow antidiagonals in just one quadrant.

Programs

  • Mathematica
    a[n_] := a[n - 1] + If[ IntegerQ@ Sqrt@ n || IntegerQ@ Sqrt[4n +1], 2 - Select[{Sqrt@ n, (Sqrt[4n +1] -1)/2}, IntegerQ][[1]], 1]; a[0] = 0; Array[a, 76, 0] (* Robert G. Wilson v, Dec 25 2016 *)

Formula

Empirically: a(0)=0, a(n+1)=a(n)+d for n>0, when n=k^2 or n=k*(k+1) then d=2-k, else d=1.

Extensions

Corrected a(23) and more terms from Lars Blomberg, Dec 25 2016

A274917 Square spiral in which each new term is the least positive integer distinct from its (already assigned) eight neighbors.

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Jul 11 2016

Keywords

Comments

The largest element is 5 and it is also the element with lower density in the spiral.
See A275609 for proof that 5 is maximal and for further comments. - N. J. A. Sloane, Mar 24 2019

Examples

			Illustration of initial terms as a spiral (n = 0..168):
.
.     2 - 3 - 2 - 1 - 5 - 1 - 3 - 1 - 2 - 4 - 2 - 4 - 2
.     |                                               |
.     4   1 - 4 - 3 - 2 - 4 - 2 - 4 - 3 - 1 - 3 - 1   3
.     |   |                                       |   |
.     2   3   2 - 1 - 5 - 1 - 3 - 1 - 2 - 4 - 2   4   2
.     |   |   |                               |   |   |
.     1   5   4   3 - 2 - 4 - 2 - 4 - 3 - 1   3   1   3
.     |   |   |   |                       |   |   |   |
.     4   2   1   5   1 - 3 - 1 - 5 - 2   4   2   4   2
.     |   |   |   |   |               |   |   |   |   |
.     1   3   4   2   4   2 - 4 - 3   1   3   1   3   1
.     |   |   |   |   |   |       |   |   |   |   |   |
.     4   2   1   3   1   3   1 - 2   4   2   4   2   4
.     |   |   |   |   |   |           |   |   |   |   |
.     1   3   4   2   4   2 - 4 - 3 - 1   3   1   3   1
.     |   |   |   |   |                   |   |   |   |
.     4   2   1   3   1 - 3 - 1 - 2 - 4 - 2   4   2   4
.     |   |   |   |                           |   |   |
.     1   3   4   2 - 4 - 2 - 4 - 3 - 1 - 3 - 1   3   1
.     |   |   |                                   |   |
.     4   2   1 - 3 - 1 - 3 - 1 - 2 - 4 - 2 - 4 - 2   4
.     |   |                                           |
.     1   3 - 4 - 2 - 4 - 2 - 4 - 3 - 1 - 3 - 1 - 3 - 1
.     |
.     2 - 5 - 1 - 3 - 1 - 3 - 1 - 2 - 4 - 2 - 4 - 2 - 4
.
a(13) = 5 is the first "5" in the sequence and its four neighbors are 4 (southwest), 3 (south), 1 (southeast) and 2 (east) when a(13) is placed in the spiral.
a(157) = 5 is the 6th "5" in the sequence and it is also the first "5" that is below the NE-SW main diagonal of the spiral (see the second term in the last row of the above diagram).
		

Crossrefs

Cf. A274913, A274921, A275609, A278354 (number of neighbors).

Formula

a(n) = A275609(n) + 1. - Omar E. Pol, Nov 14 2016
Showing 1-6 of 6 results.