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.

A356257 Irregular triangle: row n consists of the frequencies of positive distances between permutations P and reverse(P), as P ranges through the permutations of (1, 2, ..., n); see Comments.

Original entry on oeis.org

1, 2, 4, 2, 8, 16, 24, 16, 32, 32, 16, 48, 192, 192, 288, 192, 144, 576, 576, 576, 576, 960, 576, 576, 288, 384, 2304, 4608, 7680, 9216, 6912, 9216, 1920, 1536, 9216, 9216, 16128, 18432, 29184, 26112, 36864, 32256, 41472, 23040, 39168, 32256, 18432, 18432
Offset: 1

Views

Author

Clark Kimberling, Oct 04 2022

Keywords

Comments

For n >= 1, let P = (p(1),p(2),...,p(n)) and Q = (q(1),q(2),...,q(n)) be permutations of (1,2,...,n). The distance between P and Q is defined by |p(1)-q(1)| + |p(2)-q(2)| + ... + |p(n)-q(n)|. For fixed n >= 1, let m be the least distance that occurs and let M be the greatest. If n is odd, let S = (m, m+2, m+4, ..., M); if n > 2 is even, let S = (m, m+4, m+8, ..., M). Then S gives all the positive distances that occur, and the frequencies in row n of the array account for the distances in S. Four open questions about the numbers in row n follow. (1) How many are there? (2) What are the first and last? (3) What are the least and greatest? (4) What is the greatest common divisor?

Examples

			First 8 rows:
    1
    2
    4      2
    8     16
   24     16    32    32    16
   48    192   192   288
  192    144   576   576   576   576    960    576    576    288
  384   2304  4608  7680  9216  6912   9216
For n=3, the 6 permutations and their reverses are represented by
  123 132 213 231 212 321
  321 231 312 132 213 123,
so the 6 distances are 4,2,2,2,2,4, whence row 3 accounts for four 2's and two 4's.
		

Crossrefs

Cf. A000142 (row sums), A357329.

Programs

  • Mathematica
    p[n_] := p[n] = Permutations[Range[n]];
    f[n_, k_] := f[n, k] = Abs[p[n][[k]] - Reverse[p[n][[k]]]]
    c[n_, k_] := c[n, k] = Total[f[n, k]]
    t[n_] := t[n] = Table[c[n, k], {k, 1, n!}]
    z = 6; Table[t[n], {n, 1, z}]
    u = Table[Count[t[n], k], {n, 1, z}, {k, Min[t[n]], Max[t[n]], 2}]
    v[n_] := Select[u[[n]], # > 0 &]
    w = Table[v[n], {n, 1, z}]
    TableForm[w] (* 356257 array *)
    Flatten[w]   (* 356257 sequence *)