OFFSET
1,2
LINKS
Robert Israel, Table of n, a(n) for n = 1..372
FORMULA
a(1)=1, a(n)=n*a(n-1)+(-1)^n*n ; a(n)=round(n!*(2-exp(-1)))+(-1)^n. - Benoit Cloitre, Sep 24 2006
E.g.f.: t*(exp(-t)-2)/(t-1). - Robert Israel, Aug 04 2014
a(n) = ((n-2)*n/(n-1))*a(n-1) + n*a(n-2). - Robert Israel, Aug 04 2014
MAPLE
a[1]:= 1:
for n from 2 to 30 do a[n]:= n*(a[n-1]+(-1)^n) od:
seq(a(n), n=1..30); # Robert Israel, Aug 04 2014
MATHEMATICA
nxt[{n_, a_}]:={n+1, If[OddQ[n], (n+1)(a+1), (n+1)(a-1)]}; Transpose[ NestList[ nxt, {1, 1}, 30]][[2]] (* Harvey P. Dale, Aug 04 2014 *)
PROG
(PARI) a(n)=if(n<2, 1, n*a(n-1)+(-1)^n*n) \\ Benoit Cloitre, Sep 24 2006
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Jul 04 2003
EXTENSIONS
More terms from Sam Alexander, Feb 26 2004
Corrected and extended by Harvey P. Dale, Aug 04 2014
STATUS
approved