OFFSET
0,4
LINKS
Index entries for linear recurrences with constant coefficients, signature (6,-10,3).
FORMULA
a(n) = 3*a(n-1) + (3^(n-2) - a(n-2)).
G.f.: x^2/((1-3*x)*(1-3*x+x^2)). a(n) = 3^n - A001906(n+1). - Bruno Berselli, Feb 23 2011
EXAMPLE
The recursive formula is based on extending such a string of length n-1 with {0,1,2} or extending a non-matching string of length (n-2) with "01". For n=2, there is just 1 string: "01". For n=3, we append {0,1,2} to "01" and append "01" to {"0","1","2"}, the three non-matching strings of length 1, for a total of a(3)=6.
MATHEMATICA
nn=20; CoefficientList[Series[1/(1-3x)-1/(x^2+(1-3x)), {x, 0, nn}], x] (* Geoffrey Critzer, Dec 25 2013 *)
LinearRecurrence[{6, -10, 3}, {0, 0, 1}, 30] (* Harvey P. Dale, Jun 14 2020 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Toby Gottfried, Feb 17 2011
STATUS
approved