login
A142879
a(n) = 5*a(n-3) - a(n-6) with terms 1..6 as 0, 1, 2, 5, 7, 9.
1
0, 1, 2, 5, 7, 9, 25, 34, 43, 120, 163, 206, 575, 781, 987, 2755, 3742, 4729, 13200, 17929, 22658, 63245, 85903, 108561, 303025, 411586, 520147, 1451880, 1972027, 2492174, 6956375, 9448549, 11940723, 33329995, 45270718, 57211441, 159693600
OFFSET
1,3
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
EXTENSIONS
New name from Colin Barker and Charles R Greathouse IV, Jan 08 2013
STATUS
approved