OFFSET
0,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..450
FORMULA
a(n) = (n-1)*(a(n-1)+a(n-2)), n>2. - Gary Detlefs, Apr 11 2010
a(n) = 2*n! + floor((n!+1)/e) for n>0. - Gary Detlefs, Apr 11 2010
E.g.f.: (2*exp(x)*x+1)*exp(-x)/(1-x). - Alois P. Heinz, May 07 2020
MAPLE
a:= proc(n) option remember;
`if`(n<2, n+1, n*a(n-1)+(-1)^n)
end:
seq(a(n), n=0..23); # Alois P. Heinz, May 07 2020
MATHEMATICA
a[n_] := Subfactorial[n] + 2 Boole[n > 0] n!;
Table[a[n], {n, 0, 23}] (* Jean-François Alcover, Mar 18 2022 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Philippe Deléham, Sep 04 2005
EXTENSIONS
a(0)=1 prepended and two terms corrected by Alois P. Heinz, May 07 2020
STATUS
approved