OFFSET
0,3
COMMENTS
A sequentially switched sequence modulo 3.
LINKS
Colin Barker, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (0,0,2,0,0,1,0,0,-1).
FORMULA
From Colin Barker, Nov 18 2015: (Start)
a(n) = 2*a(n-3)+a(n-6)-a(n-9) for n>11.
G.f.: -(x^11+x^10-2*x^9-2*x^8+2*x^7+3*x^6-3*x^4-x^3-2*x^2-x-1) / (x^9-x^6-2*x^3+1).
(End)
MAPLE
a:= proc(n) option remember; add(a(n-i), i=1+(n mod 3)..1+2*(n mod 3)) end proc:
a(0):= 1: a(1):= 1: a(2):= 2: a(3):= 3: a(4):= 5:
seq(a(n), n=0..100); # Robert Israel, Nov 18 2015
MATHEMATICA
a[n_Integer?Positive] := If[Mod[n, 3] == 0, a[n] = a[n - 1], If[Mod[n, 3] == 1, a[n] = a[n - 2] + a[n - 3], a[n] = a[n - 3] + a[n - 4] + a[n - 5]]] a[0] = 1; a[1] = 1; a[2] = 2; a[3] = 3; a[4] = 5; aa = Table[a[n], {n, 0, 200}]
nxt[{n_, a_, b_, c_, d_, e_}]:={n+1, b, c, d, e, Which[Mod[n+1, 3]==0, e, Mod[n+1, 3]==1, c+d, Mod[n+1, 3]==2, a+b+c]}; NestList[nxt, {4, 1, 1, 2, 3, 5}, 100][[;; , 2]] (* or *) LinearRecurrence[{0, 0, 2, 0, 0, 1, 0, 0, -1}, {1, 1, 2, 3, 5, 4, 4, 9, 12, 12, 21, 25}, 100] (* Harvey P. Dale, Nov 17 2024 *)
PROG
(PARI) Vec(-(x^11+x^10-2*x^9-2*x^8+2*x^7+3*x^6-3*x^4-x^3-2*x^2-x-1)/(x^9-x^6-2*x^3+1) + O(x^60)) \\ Colin Barker, Nov 18 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Roger L. Bagula, Mar 13 2005
EXTENSIONS
Typos in title and formula fixed by Colin Barker, Nov 18 2015
STATUS
approved