OFFSET
1,5
COMMENTS
Beginning with a(0)=0, a(1)=1 gives 0, 1, 2, 4, 8, 16, ..., 2^(n-1).
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..400
FORMULA
D-finite with recurrence: a(n) = n*a(n-1) - 2*(n-2)*a(n-2), a(1)=1, a(2)=1. - Georg Fischer, Jun 18 2021
a(n) = e^(-2)*( - Gamma(n)*E_{n}(-2) + 2^(n-1)*(-Ei(2) + e^2 - Pi*i), where Ei(x) and E_{n}(x) are exponential integrals. - G. C. Greubel, Sep 03 2021
EXAMPLE
a(7) = 6*(-36) - 5(-6) - 4*0 - 3*1 - 2*1 - 1*1 = -216 + 30 - 0 - 3 - 2 - 1 = -192.
MAPLE
nmax:=24; a[1]:=1: a[2]:=1: for n from 3 to nmax do a[n]:=(n-1)*a[n-1]-add(k*a[k], k=1..n-2) od: seq(a[n], n=1..nmax); # Emeric Deutsch, Feb 03 2006
MATHEMATICA
RecurrenceTable[{a[n]==n*a[n-1] - 2*(n-2)*a[n-2], a[1]==a[2]==1}, a[n], {n, 1, 20}] (* Georg Fischer, Jun 18 2021 *)
PROG
(Magma) [n le 2 select 1 else n*Self(n-1) - 2*(n-2)*Self(n-2): n in [1..30]]; // G. C. Greubel, Sep 03 2021
(Sage)
def a(n): return 1 if (n<3) else n*a(n-1) - 2*(n-2)*a(n-2)
[a(n) for n in (1..30)] # G. C. Greubel, Sep 03 2021
CROSSREFS
KEYWORD
easy,sign
AUTHOR
Alexandre Wajnberg, May 08 2005
EXTENSIONS
More terms from Emeric Deutsch, Feb 03 2006
Definition adapted to offset by Georg Fischer, Jun 18 2021
STATUS
approved