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.

A368604 Triangular array T, read by rows: T(n,k) = number of sums |x-y|+|y-z| = k, where x,y,z are in {1,2,...,n} and x < y and y > z.

Original entry on oeis.org

0, 1, 0, 2, 2, 1, 3, 4, 4, 2, 4, 6, 7, 6, 4, 5, 8, 10, 10, 9, 6, 6, 10, 13, 14, 14, 12, 9, 7, 12, 16, 18, 19, 18, 16, 12, 8, 14, 19, 22, 24, 24, 23, 20, 16, 9, 16, 22, 26, 29, 30, 30, 28, 25, 20, 10, 18, 25, 30, 34, 36, 37, 36, 34, 30, 25, 11, 20, 28, 34, 39
Offset: 1

Views

Author

Clark Kimberling, Jan 22 2024

Keywords

Comments

The difference sequence of the k-th column is (k), for k >= 1.

Examples

			First nine rows:
  0
  1    0
  2    2    1
  3    4    4    2
  4    6    7    6    4
  5    8   10   10    9    6
  6   10   13   14   14   12    9
  7   12   16   18   19   18   16   12
  8   14   19   22   24   24   23   20   16
For n=3, there are 5 triples (x,y,z) having x < y and y > z:
121:  |x-y| + |y-z| = 2
131:  |x-y| + |y-z| = 4
132:  |x-y| + |y-z| = 3
231:  |x-y| + |y-z| = 3
232:  |x-y| + |y-z| = 2
so that row 1 of the array is (2,2,1), representing two 2s, two 3s, and one 4.
		

Crossrefs

Cf. A000027 (column 1), A002620 (T(n,n)), A002717 (row sums), A368434, A368437, A368515, A368516, A368517, A368518, A368519, A368521, A368522.

Programs

  • Mathematica
    t1[n_] := t1[n] = Tuples[Range[n], 3];
    t[n_] := t[n] = Select[t1[n], #[[1]] < #[[2]] > #[[3]] &];
    a[n_, k_] := Select[t[n], Abs[#[[1]] - #[[2]]] + Abs[#[[2]] - #[[3]]] == k &];
    u = Table[Length[a[n, k]], {n, 1, 15}, {k, 2, n + 1}];
    v = Flatten[u]
    Column[Table[Length[a[n, k]], {n, 1, 15}, {k, 2, n + 1}]]