OFFSET
1,2
FORMULA
E.g.f.: (2-exp(-x))/(1-x) (if offset 0).
a(n) = (n-1)! + A002467(n-1), n > 0. (index corrected Mar 07 2022)
D-finite with recurrence a(n+2) = n(a(n) + a(n+1)) for n > 0. - Amarnath Murthy, Oct 05 2002
a(n) = 2*(n-1)! - floor(((n-1)! + 1)/e), n > 1. - Gary Detlefs, Apr 11 2010
MAPLE
a:= proc(p) option remember; p*a(p-1)-(-1)^p end proc: a(0):= 1: seq(a(p), p=0..19); # Robert Israel, Jan 05 2008
MATHEMATICA
a[0] = 1; a[p_] := p*a[p - 1] -(-1)^p; a /@ Range[0, 19] (* Zerinvary Lajos, Mar 29 2007 *)
FoldList[#1*#2 - (-1)^#2 &, 1, Range[19]] (* Robert G. Wilson v, Jul 07 2012 *)
RecurrenceTable[{a[n + 1] == n a[n] - (-1)^n, a[1] == 1}, a[n], {n, 21}] (* Ray Chandler, Jul 30 2015 *)
PROG
(PARI) a(n)=if(n<2, n>0, (n-1)*a(n-1)+(-1)^n)
(PARI) a(n)=if(n<1, 0, (n-1)!*polcoeff((2-exp(-x+O(x^n)))/(1-x), n-1))
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved