login
A085110
a(1)=1, then add 1 multiply by 2 to get a(2), subtract 1 and multiply by 3 to get a(3), add 1 and multiply by 4 to get a(4) and so on.
1
1, 4, 9, 40, 195, 1176, 8225, 65808, 592263, 5922640, 65149029, 781788360, 10163248667, 142285481352, 2134282220265, 34148515524256, 580524763912335, 10449445750422048, 198539469258018893, 3970789385160377880, 83386577088367935459, 1834504695944094580120
OFFSET
1,2
LINKS
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
Sequence in context: A370602 A354738 A073414 * A374939 A013459 A041229
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