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.

A139365 Array of digit sums of factorial representation of numbers 0,1,...,n!-1 for n >= 1.

Original entry on oeis.org

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

Views

Author

Wolfdieter Lang, May 21 2008

Keywords

Comments

The row lengths sequence is A000142 (factorials).
When the factorial representation is read as (D. N.) Lehmer code for permutations of n objects then the digit sums in row n count the inversions of the permutations arranged in lexicographic order.
Row n is the first n! terms of A034968. - Franklin T. Adams-Watters, May 13 2009

Examples

			n=3: The Lehmer codes for the permutations of {1,2,3} are [0,0,0], [0,1,0], [1,0,0], [1,1,0], [2,0,0] and [2,1,0]. These are the factorial representations for 0,1,...,5=3!-1. Therefore row n=3 has the digit sums 0,1,1,2,2,3, the number of inversions of the permutations [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2] and [3,2,1] (lexicographic order).
Triangle begins:
  0;
  0;
  0, 1;
  0, 1, 1, 2, 2, 3;
  0, 1, 1, 2, 2, 3, 1, 2, 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, 3, 4, 4, 5, 5, 6;
  ...
		

Crossrefs

Cf. A008302.
Row sums give A001809.

Programs

  • Mathematica
    nn = 5; m = 1; While[Factorial@ m < nn! - 1, m++]; m; Table[Total@ IntegerDigits[k, MixedRadix[Reverse@ Range[2, m]]], {n, 0, 5}, {k, 0, n! - 1}] // Flatten (* Version 10.2, or *)
    f[n_] := Block[{a = {{0, n}}}, Do[AppendTo[a, {First@ #, Last@ #} &@ QuotientRemainder[a[[-1, -1]], Times @@ Range[# - i]]], {i, 0, #}] &@ NestWhile[# + 1 &, 0, Times @@ Range[# + 1] <= n &]; Most@ Rest[a][[All, 1]]]; Table[Total@ f@ k, {n, 0, 5}, {k, 0, n! - 1}] // Flatten (* Michael De Vlieger, Aug 29 2016 *)

Formula

Row n >= 1: sum(facrep(n,m)[n-j],j=1..n), m=0,1,...,n!-1, with the factorial representation facrep(n,m) of m for given n.
T(n,n!-1) = A161680(n). - Alois P. Heinz, Jan 20 2025

Extensions

Zeroth row added by Franklin T. Adams-Watters, May 13 2009