login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A104204
If n==0 (mod 3) then a(n)=a(n-1); if n==1 (mod 3) then a(n)=a(n-2)+a(n-3); if n==2 (mod 3) then a(n)=a(n-3)+a(n-4)+a(n-5).
1
1, 1, 2, 3, 5, 4, 4, 9, 12, 12, 21, 25, 25, 46, 58, 58, 104, 129, 129, 233, 291, 291, 524, 653, 653, 1177, 1468, 1468, 2645, 3298, 3298, 5943, 7411, 7411, 13354, 16652, 16652, 30006, 37417, 37417, 67423, 84075, 84075, 151498, 188915, 188915, 340413, 424488
OFFSET
0,3
COMMENTS
A sequentially switched sequence modulo 3.
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
Sequence in context: A023818 A102149 A321782 * A131296 A371216 A267808
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