OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..448
Wikipedia, Derangement
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
KEYWORD
nonn
AUTHOR
Alois P. Heinz, May 08 2020
STATUS
approved