OFFSET
0,6
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..6000
Wikipedia, Inversion (discrete mathematics)
EXAMPLE
a(3) = 1: 21.
a(4) = 1: 31.
a(5) = 2: 41, 32.
a(6) = 11: one inversion in each of 51, 132, 42, 213, two inversions in each of 231, 312, three inversions in 321.
MAPLE
b:= proc(n, i, t) option remember; `if`(n>i*(i+1)/2, 0,
`if`(n=0, t!*t*(t-1)/4, b(n, i-1, t)+
`if`(i>n, 0, b(n-i, i-1, t+1))))
end:
a:= n-> b(n$2, 0):
seq(a(n), n=0..60);
MATHEMATICA
b[n_, i_, t_] := b[n, i, t] = If[n > i*(i + 1)/2, 0, If[n == 0, t!*t*(t - 1)/4, b[n, i - 1, t] + If[i > n, 0, b[n - i, i - 1, t + 1]]]];
a[n_] := b[n, n, 0];
Table[a[n], {n, 0, 60}] (* Jean-François Alcover, May 29 2018, from Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Apr 05 2016
STATUS
approved