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.
%I A282087 #19 Apr 07 2020 23:15:53 %S A282087 1,3,9,27,79,229,657,1871,5295,14909,41801,116783,325287,903741, %T A282087 2505377,6932479,19151519,52833853,145578265,400705135,1101936119, %U A282087 3027902045,8314284721,22816209855,62579270191,171559358493,470132335209,1287861941487,3526800739399 %N A282087 Number of length-n ternary strings that do not contain both "00" and "11". %H A282087 Colin Barker, <a href="/A282087/b282087.txt">Table of n, a(n) for n = 0..1000</a> %H A282087 Math StackExchange, <a href="http://math.stackexchange.com/questions/2128688/find-a-recurrence-relation-for-the-number-of-ternary-strings-of-length-%DD%8A-that-do/2129218#2129218">Find a recurrence relation for the number of ternary strings of length ? that do not contain two consecutive 0's and two consecutive 1's</a>. %H A282087 <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (4,-1,-6,-2). %F A282087 a(n) = 4*a(n-1) - a(n-2) - 6*a(n-3) - 2*a(n-4) for n >= 4 (derived in the math.stackexchange.com link). %F A282087 From _Colin Barker_, Feb 07 2017: (Start) %F A282087 a(n) = -(1-u)^(1+n)/2 - (1+u)^(1+n)/2 + (1-v)^n - (2*(1-v)^n)/v + (1+v)^n + (2*(1+v)^n) / v where u=sqrt(2) and v=sqrt(3). %F A282087 G.f.: (1 + x)*(1 - 2*x) / ((1 - 2*x - x^2)*(1 - 2*x - 2*x^2)). %F A282087 (End) %e A282087 for n=5 the 229 acceptable ternary strings are all length 5 strings of '0', '1', and '2' _except_ '00011', '00110', '00111', '00112', '00211', '01100', '10011', '11000', '11001', '11002', '11100', '11200', '20011', '21100'. %t A282087 Table[3^n, {n, 0, 3}]~Join~LinearRecurrence[{4, -1, -6, -2}, {79, 229, 657, 1871}, 24] (* or *) %t A282087 Table[Count[Tuples[Range[0, 2], n], w_ /; Boole[SequenceCount[w, {0, 0}] > 0] Boole[SequenceCount[w, {1, 1}] > 0] == 0], {n, 0, 12}] (* _Michael De Vlieger_, Feb 05 2017, latter program version 10.1 *) %o A282087 (Python) %o A282087 import itertools %o A282087 # Not feasible on most machines for large numbers %o A282087 def find_a_sub_n(n): %o A282087 c = 0 %o A282087 for q in itertools.product(*([['0','1','2']]*n)): %o A282087 h = ''.join(q) %o A282087 if not (('11' in h) and ('00' in h)): %o A282087 c = c+1 %o A282087 return c %o A282087 (PARI) a(n)=([0,1,0,0;0,0,1,0;0,0,0,1;-2,-6,-1,4]^n*[1;3;9;27])[1,1] \\ _Charles R Greathouse IV_, Feb 05 2017 %o A282087 (PARI) Vec((1 + x)*(1 - 2*x) / ((1 - 2*x - x^2)*(1 - 2*x - 2*x^2)) + O(x^30)) \\ _Colin Barker_, Feb 07 2017 %Y A282087 Cf. A078057 (number of length-n ternary strings that contain neither "00" nor "11"). %K A282087 nonn,easy %O A282087 0,2 %A A282087 _Daniel T. Martin_, Feb 05 2017