OFFSET
1,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (3, 1, -3).
FORMULA
From R. J. Mathar, Oct 05 2009: (Start)
a(n) = 3*a(n-1) + a(n-2) - 3*a(n-3).
G.f.: x*(-1 + x + x^2)/((1-x) * (3*x-1) * (1+x)).
a(n) = (5*3^n + 6 - 3*(-1)^n)/24. (End)
E.g.f.: (1/24)*(-3*exp(-x) - 8 + 6*exp(x) + 5*exp(3*x)). - G. C. Greubel, Aug 27 2016
EXAMPLE
a(2) = 3*1 - 1 = 2.
a(3) = 3*a(2) = 6.
a(4) = 3*a(3) - 1 = 17.
MATHEMATICA
Table[(5*3^n + 6 - 3*(-1)^n)/24 , {n, 1, 25}] (* or *) LinearRecurrence[{3, 1, -3}, {1, 2, 6}, 25] (* G. C. Greubel, Aug 27 2016 *)
RecurrenceTable[{a[1] == 1, a[2] == 2, a[3] == 6, a[n] == 3 a[n-1] + a[n-2] - 3 a[n-3]}, a, {n, 30}] (* Vincenzo Librandi, Aug 28 2016 *)
PROG
(Magma) I:=[1, 2, 6]; [n le 3 select I[n] else 3*Self(n-1)+Self(n-2)-3*Self(n-3): n in [1..30]]; // Vincenzo Librandi, Aug 28 2016
(PARI) a(n) = (3^n*5)\/24 \\ Charles R Greathouse IV, Aug 28 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Clark Kimberling, Jan 01 2009
STATUS
approved