OFFSET
0,3
LINKS
Colin Barker, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1, 0, 1, -1).
FORMULA
From Colin Barker, Nov 19 2015: (Start)
a(n) = a(n-3) + 2 for n>2.
a(n) = a(n-1) + a(n-3) - a(n-4) for n>3.
G.f.: 2*x^2*(2 - x) / ((1 - x)^2*(1 + x + x^2)). (End)
a(n) = (2/3)*(1 + n - (1 + n mod 3)*(-1)^(-n mod 3)). [Bruno Berselli, Nov 19 2015]
a(n) = (2/9)*(3*n+3+9*cos(2*(n-2)*Pi/3)+sqrt(3)*sin(2*(n-2)*Pi/3)). - Wesley Ivan Hurt, Oct 01 2017
MATHEMATICA
RecurrenceTable[{a[0] == a[1] == 0, a[n] == 2 n - a[n - 1] - a[n - 2]}, a, {n, 0, 70}] (* Bruno Berselli, Nov 19 2015 *)
LinearRecurrence[{1, 0, 1, -1}, {0, 0, 4, 2}, 70] (* Harvey P. Dale, Jan 20 2020 *)
PROG
(PARI) a(n)=if(n<2, 0, 2*n-a(n-1)-a(n-2))
(PARI) first(m)=my(v=vector(m)); v[1]=0; v[2]=0; for(i=3, m, v[i]=2*(i-1)-v[i-1]-v[i-2]); v
(PARI) concat(vector(2), Vec(-2*x^2*(x-2)/((x-1)^2*(x^2+x+1)) + O(x^100))) \\ Colin Barker, Nov 19 2015
(Magma) [(2/3)*(1+n-(1+n mod 3)*(-1)^(-n mod 3)): n in [0..70]]; // Bruno Berselli, Nov 19 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Anders Hellström, Nov 18 2015
STATUS
approved