OFFSET
0,4
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..200
FORMULA
a(n) = n*!n - (-1)^n, where !n = A000166(n) is subfactorial. - Vladimir Reshetnikov, Nov 03 2015
(2n + 1) a(n+2) = (2n^2 + 5n + 4) a(n+1) + (2n^2 + 5n + 3) a(n). E.g.f.: exp(-x)*(2*x-1)/(x-1)^2. - Robert Israel, Nov 03 2015
MAPLE
a:=n->sum((-1)^k * (n-k-1) * n!/k!, k=0..n): seq(a(n), n=0..20); # Zerinvary Lajos, Jun 27 2007
A000166:= gfun:-rectoproc({a(0)=1, a(1)=0, a(n) = (n-1)*(a(n-1)+a(n-2))}, a(n), remember):
MATHEMATICA
Table[Subfactorial[n] - Subfactorial[n - 1], {n, 1, 22}] (* Zerinvary Lajos, Jul 09 2009 *)
Table[n Subfactorial[n] - (-1)^n, {n, 0, 20}] (* Vladimir Reshetnikov, Nov 01 2015 *)
Differences[Table[(-1)^n HypergeometricPFQ[{-n, 1}, {}, 1], {n, 0, 20}]] (* Peter Luschny, Nov 03 2015 *)
CROSSREFS
KEYWORD
sign
AUTHOR
N. J. A. Sloane, Apr 27 2005
STATUS
approved