login
A236438
a(n) = n*a(n-1) + (-1)^n for n>0, a(0)=2.
2
2, 1, 3, 8, 33, 164, 985, 6894, 55153, 496376, 4963761, 54601370, 655216441, 8517813732, 119249392249, 1788740883734, 28619854139745, 486537520375664, 8757675366761953, 166395831968477106, 3327916639369542121, 69886249426760384540, 1537497487388728459881
OFFSET
0,1
LINKS
FORMULA
E.g.f.: (1 + exp(-x)) / (1 - x).
a(n) = A001120(n) unless n=0.
a(n) = A000166(n) + n!.
0 = a(n) * (a(n+1) + a(n+2) - a(n+3)) + a(n+1) * (a(n+1) + 2*a(n+2) - a(n+3)) + a(n+2) * (a(n+2)) if n>=0.
a(n) = Gamma(n+1) + Gamma(n+1, -1)*exp(-1). - Peter Luschny, Feb 28 2017
D-finite with recurrence a(n) +(-n+1)*a(n-1) +(-n+1)*a(n-2)=0. - R. J. Mathar, Sep 24 2021
EXAMPLE
G.f. = 2 + x + 3*x^2 + 8*x^3 + 33*x^4 + 164*x^5 + 985*x^6 + 6894*x^7 + ...
MAPLE
a := n -> GAMMA(n+1) + GAMMA(n+1, -1)*exp(-1):
seq(simplify(a(n)), n=0..22); # Peter Luschny, Feb 28 2017
MATHEMATICA
a[ n_] := If[ n < 0, 0, n! + Subfactorial[n]]
a[ n_] := If[ n < 1, 2 Boole[n == 0], n! + Round[ n! / E]]
a[ n_] := If[ n < 0, 0, n! + (-1)^n HypergeometricPFQ[ { -n, 1}, {}, 1]]
a[ n_] := If[ n<0, 0, n! SeriesCoefficient[ (1 + Exp[ -x]) / (1 - x), {x, 0, n}]]
PROG
(PARI) {a(n) = if( n<1, 2 * (n==0), n * a(n-1) + (-1)^n)}
(PARI) {a(n) = if( n<0, 0, n! * polcoeff( (1 + exp(-x + x * O(x^n))) / (1 - x), n))}
(Magma) m:=50; R<x>:=PowerSeriesRing(Rationals(), m); b:=Coefficients(R!((1+Exp(-x))/(1-x))); [Factorial(n-1)*b[n]: n in [1..m]]; // G. C. Greubel, Aug 07 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Michael Somos, Jan 25 2014
STATUS
approved