OFFSET
0,5
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..450
Wikipedia, Permutation
EXAMPLE
a(0) = 1: the empty permutation.
a(1) = 1: 1.
a(3) = 1: 213.
a(4) = 3: 1432, 2314, 3124.
a(5) = 13: 13542, 15243, 21435, 23415, 24135, 31425, 34125, 34215, 41235, 42351, 43125, 43215, 52314.
a(6) = 64: 123564, 123645, 132654, 134652, 136254, ..., 542136, 542316, 621435, 625413, 625431.
MAPLE
g:= proc(n) option remember; `if`(n=0, 1, n*g(n-1)+(-1)^n) end:
b:= proc(n, i, m) option remember; `if`(n>i*(i+1)/2, 0,
`if`(n=0, g(m), b(n, i-1, m)+b(n-i, min(n-i, i-1), m-1)))
end:
a:= n-> b(n$3):
seq(a(n), n=0..23);
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Mar 02 2024
STATUS
approved