login
a(n) = (n+1) a(n-1) + (-1)^n.
(Formerly M3018)
4

%I M3018 #43 Nov 07 2017 18:16:26

%S 0,1,3,16,95,666,5327,47944,479439,5273830,63285959,822717468,

%T 11518044551,172770668266,2764330692255,46993621768336,

%U 845885191830047,16071818644770894,321436372895417879,6750163830803775460

%N a(n) = (n+1) a(n-1) + (-1)^n.

%C a(n) is a function of the subfactorials .. a(n) = (n+1)!/2 - A000166(n+1) - _Gary Detlefs_, Apr 16 2010

%C a(n) can be seen indeed as a shifted-forward version of the subfactorials (or derangement numbers). - _Olivier GĂ©rard_, Feb 23 2015

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H Indranil Ghosh, <a href="/A006347/b006347.txt">Table of n, a(n) for n = 1..448</a>

%H J. A. Sharp & N. J. A. Sloane, <a href="/A002026/a002026.pdf">Correspondence, 1977</a>

%F E.g.f.: x(1 - x/2 - exp(-x))/(1-x)^2.

%F a(n) = round((1/2 - exp(-1))*(n+1)!). - _Benoit Cloitre_, Sep 24 2006

%F a(n) = n(a(n-1) + a(n-2)), n > 2. - _Gary Detlefs_, Apr 10 2010

%F a(n) = 1/2*(n+1)! - floor(((n+1)!+1)/e). - _Gary Detlefs_, Apr 16 2010

%e 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

%p a:=n->-n!*sum((-1)^k/k!, k=3..n): seq(a(n), n=2..21); # _Zerinvary Lajos_, May 25 2007

%p seq(1/2*(n+1)! -floor(((n+1)!+1)/e),n=1..30); # _Gary Detlefs_, Apr 16 2010

%t RecurrenceTable[{a[1] == 0, a[n] == (n + 1) a[n - 1] + (-1)^n}, a, {n, 20}] (* _Harvey P. Dale_, Oct 19 2012 *)

%o (PARI) a(n)=if(n<2,0,(n+1)*a(n-1)+(-1)^n)

%o (PARI) a(n)=round((1/2-exp(-1))*(n+1)!) \\ _Benoit Cloitre_, Sep 24 2006

%Y Cf. A000166.

%K nonn,easy

%O 1,3

%A _N. J. A. Sloane_