OFFSET
1,3
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,0,5,0,0,-1).
FORMULA
a(n) = 2*a(n - 1) + a(n - 2) if 3 | n, a(n) = a(n - 1) + a(n - 2) if n = 1 mod 3, and a(n) = 2*a(n - 1) - a(n - 2) if n = 2 mod 3.
G.f.: x^2*(1+2*x+5*x^2+2*x^3-x^4) / (1-5*x^3+x^6). - Colin Barker, Jan 08 2013
MATHEMATICA
Clear[a, n]; a[0] = 0; a[1] = 1; a[n_] := a[n] = If[Mod[n, 3] == 0, 2*a[n - 1] + a[n - 2], If[Mod[n, 3] == 1, a[n - 1] + a[n - 2], 2*a[n - 1] - a[n - 2]]]; b = Table[a[n], {n, 0, 50}]
LinearRecurrence[{0, 0, 5, 0, 0, -1}, {0, 1, 2, 5, 7, 9}, 40] (* Harvey P. Dale, Apr 06 2016 *)
PROG
(PARI) a=vector(20); a[1]=1; a[2]=2; for(n=3, #a, if(n%3==0, a[n]=2*a[n-1]+a[n-2], if(n%3==1, a[n]=a[n-1]+a[n-2], a[n]=2*a[n-1]-a[n-2]))); concat(0, a) \\ Colin Barker, Jan 30 2016
(PARI) concat(0, Vec(x^2*(1+2*x+5*x^2+2*x^3-x^4)/(1-5*x^3+x^6) + O(x^50))) \\ Colin Barker, Jan 30 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Roger L. Bagula and Gary W. Adamson, Sep 28 2008
EXTENSIONS
New name from Colin Barker and Charles R Greathouse IV, Jan 08 2013
STATUS
approved