login
A334716
a(n) = !n + n * n!, where !n = A000166(n) is subfactorial of n.
2
1, 1, 5, 20, 105, 644, 4585, 37134, 337393, 3399416, 37622961, 453769370, 5924234041, 83242063332, 1252567177849, 20096182035734, 342461702459745, 6177536369911664, 117598028364137953, 2356007639327453106, 49553054794725702121, 1091705092860949184540
OFFSET
0,3
LINKS
Wikipedia, Derangement
FORMULA
E.g.f.: x/(x-1)^2 - exp(-x)/(x-1).
a(n) = A000166(n) + A001563(n) = !n + n * n!.
MAPLE
a:= proc(n) option remember; `if`(n<3, [1, 1, 5][n+1],
((2*n+1)*(n-1)*a(n-1)-(n-1)*(n^2-2*n-2)*a(n-2)
-(n+1)*(n-1)*(n-2)*a(n-3))/n)
end:
seq(a(n), n=0..23);
MATHEMATICA
a[n_] := Subfactorial[n] + n n!;
a /@ Range[0, 23] (* Jean-François Alcover, Apr 26 2021 *)
CROSSREFS
Main diagonal of A334715.
Sequence in context: A259275 A109500 A137961 * A167145 A277032 A300490
KEYWORD
nonn
AUTHOR
Alois P. Heinz, May 08 2020
STATUS
approved