login
a(0) = a(1) = 1; for n > 1, a(n) = n*a(n-1) + (-1)^n.
(Formerly M2760 N1110)
6

%I M2760 N1110 #55 Feb 19 2024 01:47:58

%S 1,1,3,8,33,164,985,6894,55153,496376,4963761,54601370,655216441,

%T 8517813732,119249392249,1788740883734,28619854139745,486537520375664,

%U 8757675366761953,166395831968477106,3327916639369542121,69886249426760384540,1537497487388728459881

%N a(0) = a(1) = 1; for n > 1, a(n) = n*a(n-1) + (-1)^n.

%D N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

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

%H Alois P. Heinz, <a href="/A001120/b001120.txt">Table of n, a(n) for n = 0..450</a> (terms n = 1..100 from T. D. Noe)

%H J. Gebel, <a href="/A001014/a001014.txt">Integer points on Mordell curves</a> [Cached copy, after the original web site tnt.math.se.tmu.ac.jp was shut down in 2017]

%F Nearest integer to n!(1+1/e).

%F a(n) = A000166(n) + [n > 0] * n!. - _Philippe Deléham_, Sep 04 2005

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

%F E.g.f.: (exp(x)*x+1)*exp(-x)/(1-x). - _Alois P. Heinz_, May 08 2020

%p a:= proc(n) option remember;

%p `if`(n<2, 1, n*a(n-1)+(-1)^n)

%p end:

%p seq(a(n), n=0..23); # _Alois P. Heinz_, May 09 2020

%t t = {1}; Do[AppendTo[t, n*t[[-1]] + (-1)^n], {n, 2, 20}]; t (* _T. D. Noe_, Jun 26 2012 *)

%t RecurrenceTable[{a[1]==1,a[n]==n a[n-1]+(-1)^n},a,{n,30}] (* _Harvey P. Dale_, Feb 19 2018 *)

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

%o (PARI) a(n)=if(n<1,0,n!*polcoeff((1+exp(-x+x*O(x^n)))/(1-x),n))

%Y A000166 has a similar recurrence.

%Y Column k=1 of A334715.

%Y Cf. A000142.

%K nonn,easy

%O 0,3

%A _N. J. A. Sloane_, _Simon Plouffe_

%E a(0)=1 prepended by _Alois P. Heinz_, May 08 2020