login
A006347
a(n) = (n+1) a(n-1) + (-1)^n.
(Formerly M3018)
4
0, 1, 3, 16, 95, 666, 5327, 47944, 479439, 5273830, 63285959, 822717468, 11518044551, 172770668266, 2764330692255, 46993621768336, 845885191830047, 16071818644770894, 321436372895417879, 6750163830803775460
OFFSET
1,3
COMMENTS
a(n) is a function of the subfactorials .. a(n) = (n+1)!/2 - A000166(n+1) - Gary Detlefs, Apr 16 2010
a(n) can be seen indeed as a shifted-forward version of the subfactorials (or derangement numbers). - Olivier Gérard, Feb 23 2015
REFERENCES
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
J. A. Sharp & N. J. A. Sloane, Correspondence, 1977
FORMULA
E.g.f.: x(1 - x/2 - exp(-x))/(1-x)^2.
a(n) = round((1/2 - exp(-1))*(n+1)!). - Benoit Cloitre, Sep 24 2006
a(n) = n(a(n-1) + a(n-2)), n > 2. - Gary Detlefs, Apr 10 2010
a(n) = 1/2*(n+1)! - floor(((n+1)!+1)/e). - Gary Detlefs, Apr 16 2010
EXAMPLE
a(2) = (1/2)*6 - 2 = 1, a(3) = (1/2)*24 - 9 = 3, a(4) = (1/2)*120 - 44 = 16 ... - Gary Detlefs, Apr 16 2010
MAPLE
a:=n->-n!*sum((-1)^k/k!, k=3..n): seq(a(n), n=2..21); # Zerinvary Lajos, May 25 2007
seq(1/2*(n+1)! -floor(((n+1)!+1)/e), n=1..30); # Gary Detlefs, Apr 16 2010
MATHEMATICA
RecurrenceTable[{a[1] == 0, a[n] == (n + 1) a[n - 1] + (-1)^n}, a, {n, 20}] (* Harvey P. Dale, Oct 19 2012 *)
PROG
(PARI) a(n)=if(n<2, 0, (n+1)*a(n-1)+(-1)^n)
(PARI) a(n)=round((1/2-exp(-1))*(n+1)!) \\ Benoit Cloitre, Sep 24 2006
CROSSREFS
Cf. A000166.
Sequence in context: A137644 A114174 A181067 * A000270 A157051 A000271
KEYWORD
nonn,easy
STATUS
approved