OFFSET
1,2
COMMENTS
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
O.g.f.: x*(1 + 6*x + 2*x^2)/((1 + x)*(1 - x)^2).
E.g.f.: (3 + 8*exp(x) - 11*exp(2*x) + 18*x*exp(2*x))*exp(-x)/4.
a(n) = a(n-1) + a(n-2) - a(n-3).
a(n) = 2*(2*n - 1) + (2*n - 3*(1 - (-1)^n))/4. Therefore, for n even a(n) = (9*n - 4)/2, otherwise a(n) = (9*n - 7)/2.
MATHEMATICA
Table[2 (2 n - 1) + (2 n - 3 (1 - (-1)^n))/4, {n, 1, 60}]
{#+1, #+7}&/@(9*Range[0, 30])//Flatten (* or *) LinearRecurrence[{1, 1, -1}, {1, 7, 10}, 60] (* Harvey P. Dale, Nov 08 2020 *)
PROG
(GAP) a := [1, 7, 10];; for n in [4..60] do a[n] := a[n-1] + a[n-2] - a[n-3]; od; a;
(Python) [2*(2*n-1)+(2*n-3*(1-(-1)**n))/4 for n in range(1, 70)]
(Sage) [n for n in (1..300) if n % 9 in (1, 7)]
(Magma) &cat [[9*n+1, 9*n+7]: n in [0..40]];
(PARI) Vec(x*(1 + 6*x + 2*x^2) / ((1 - x)^2*(1 + x)) + O(x^60)) \\ Colin Barker, Mar 22 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Bruno Berselli, Mar 21 2018
STATUS
approved