cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A225879 Number of n-length words w over ternary alphabet {1,2,3} such that for every prefix z of w we have 0<=#(z,1)-#(z,2)<=2 and 0<=#(z,2)-#(z,3)<=2 and #(z,x) gives the number of occurrences of letter x in z.

This page as a plain text file.
%I A225879 #30 Feb 12 2024 13:29:20
%S A225879 1,1,2,3,7,14,23,51,102,167,371,742,1215,2699,5398,8839,19635,39270,
%T A225879 64303,142843,285686,467799,1039171,2078342,3403199,7559883,15119766,
%U A225879 24757991,54997523,109995046,180112335,400102427,800204854,1310302327,2910712035,5821424070
%N A225879 Number of n-length words w over ternary alphabet {1,2,3} such that for every prefix z of w we have 0<=#(z,1)-#(z,2)<=2 and 0<=#(z,2)-#(z,3)<=2 and #(z,x) gives the number of occurrences of letter x in z.
%H A225879 Alois P. Heinz, <a href="/A225879/b225879.txt">Table of n, a(n) for n = 0..1000</a>
%H A225879 <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,7,0,0,2).
%F A225879 a(3n+2) = 2*a(3n+1).
%F A225879 From _Alois P. Heinz_, May 20 2013: (Start)
%F A225879 G.f.: (x-1)*(4*x^2+2*x+1) / (2*x^6+7*x^3-1).
%F A225879 a(n) = 7*a(n-3) + 2*a(n-6) for n>5. (End)
%e A225879 For n=6 the 23 words are: 112121, 112123, 112132, 112211, 112213, 112231, 112233, 112312, 112321, 112323, 121121, 121123, 121132, 121211, 121213, 121231, 121233, 121312, 121321, 121323, 123112, 123121 and 123123.
%p A225879 a:= n-> (<<0|1>, <2|7>>^iquo(n, 3, 'r').
%p A225879         [<<1, 3>>, <<1, 7>>, <<2, 14>>][r+1])[1, 1]:
%p A225879 seq(a(n), n=0..50); # _Alois P. Heinz_, May 20 2013
%t A225879 LinearRecurrence[{0,0,7,0,0,2},{1,1,2,3,7,14},40] (* _Harvey P. Dale_, Mar 06 2015 *)
%o A225879 (JavaScript)
%o A225879 function countOK(arr) {
%o A225879 var i,c=[0,0,0];
%o A225879 for (i=0;i<arr.length;i++) c[arr[i]-1]++;
%o A225879 if (c[0]>=c[1] && c[0]-c[1]<=2 && c[1]>=c[2] && c[1]-c[2]<=2) return true; else return false;
%o A225879 }
%o A225879 x=new Array();
%o A225879 x[0]=new Array();
%o A225879 x[0][0]=[1];
%o A225879 document.write(x[0].length+", ");
%o A225879 for (i=1;i<21;i++) {
%o A225879 x[i]=new Array();
%o A225879 xc=0;
%o A225879 for (j=0;j<x[i-1].length;j++) {
%o A225879 xn=x[i-1][j].concat([1]);
%o A225879 if (countOK(xn)) x[i][xc++]=xn;
%o A225879 xn=x[i-1][j].concat([2]);
%o A225879 if (countOK(xn)) x[i][xc++]=xn;
%o A225879 xn=x[i-1][j].concat([3]);
%o A225879 if (countOK(xn)) x[i][xc++]=xn;
%o A225879 }
%o A225879 document.write(x[i].length+", ");
%o A225879 }
%Y A225879 Cf. A015555 (trisection)
%K A225879 nonn,easy
%O A225879 0,3
%A A225879 _Jon Perry_, May 19 2013