OFFSET
0,8
LINKS
Alois P. Heinz, Antidiagonals n = 0..140, flattened
Wikipedia, Derangement
Wikipedia, Iverson bracket
FORMULA
E.g.f. of column k: (k*exp(x)*x+1)*exp(-x)/(1-x).
A(n,k) = A000166(n) + [n > 0] * (k * n!).
A(n,k) = (k-1)*n + 1 if n<2, A(n,k) = n*A(n-1, k) + (-1)^n if n>=2.
EXAMPLE
Square array A(n,k) begins:
1, 1, 1, 1, 1, 1, 1, 1, ...
0, 1, 2, 3, 4, 5, 6, 7, ...
1, 3, 5, 7, 9, 11, 13, 15, ...
2, 8, 14, 20, 26, 32, 38, 44, ...
9, 33, 57, 81, 105, 129, 153, 177, ...
44, 164, 284, 404, 524, 644, 764, 884, ...
265, 985, 1705, 2425, 3145, 3865, 4585, 5305, ...
1854, 6894, 11934, 16974, 22014, 27054, 32094, 37134, ...
...
MAPLE
A:= proc(n, k) option remember; `if`(n<2,
(k-1)*n+1, n*A(n-1, k)+(-1)^n)
end:
seq(seq(A(n, d-n), n=0..d), d=0..10);
MATHEMATICA
A[n_, k_] := Subfactorial[n] + Boole[n>0] k n!;
Table[A[n, d-n], {d, 0, 10}, {n, 0, d}] // Flatten (* Jean-François Alcover, Feb 11 2021 *)
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Alois P. Heinz, May 08 2020
STATUS
approved