%I #42 May 03 2021 21:33:21
%S 1,1,2,3,2,3,4,5,4,5,6,7,6,7,8,9,8,9,10,11,10,11,12,13,12,13,14,15,14,
%T 15,16,17,16,17,18,19,18,19,20,21,20,21,22,23,22,23,24,25,24,25,26,27,
%U 26,27,28,29,28,29,30,31,30,31,32,33,32,33,34,35,34,35,36,37,36,37,38,39,38,39,40,41,40,41,42,43,42,43,44,45,44,45,46,47,46,47,48,49,48,49,50,51,50,51,52,53,52,53,54,55,54,55,56,57,56,57,58,59,58,59,60,61
%N Parse the infinite string 0101010101... into distinct phrases 0, 1, 01, 010, 10, ...; a(n) = length of n-th phrase.
%H Ray Chandler, <a href="/A187180/b187180.txt">Table of n, a(n) for n = 1..1000</a>
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,0,0,1,-1).
%F Consider more generally the string 012...k012...k012...k012...k01... with an alphabet of size B, where k = B-1. The sequence begins with B 1's, and thereafter is quasi-periodic with period B^2, and increases by B in each period.
%F For the present example, where B=2, the sequence begins with two 1's and thereafter increases by 2 in each block of 4: (1,1) (2,3,2,3), (4,5,4,5), (6,7,6,7), ...
%F From _Colin Barker_, Oct 15 2015: (Start)
%F a(n) = (1+(-1)^n+(1-i)*(-i)^n+(1+i)*i^n+2*n)/4 for n>1, where i = sqrt(-1).
%F G.f.: x*(x^5-2*x^4+x^3+x^2+1) / ((x-1)^2*(x+1)*(x^2+1)).
%F From _Wesley Ivan Hurt_, May 03 2021: (Start)
%F a(n) = a(n-1)+a(n-4)-a(n-5).
%F a(n) = floor((n+1+(-1)^floor((n+1)/2))/2) for n > 1. (End)
%e The sequence begins
%e 1 1
%e 2 3 2 3
%e 4 5 4 5
%e 6 7 6 7
%e 8 9 8 9
%e 10 11 10 11 ...
%p 1,1,seq(op(2*i*[1,1,1,1]+[0,1,0,1]), i=1..100); # _Robert Israel_, Oct 15 2015
%t Join[{1},LinearRecurrence[{1, 0, 0, 1, -1},{1, 2, 3, 2, 3},119]] (* _Ray Chandler_, Aug 26 2015 *)
%t CoefficientList[Series[(x^5 - 2 x^4 + x^3 + x^2 + 1)/((x - 1)^2 (x + 1) (x^2 + 1)), {x, 0, 150}], x] (* _Vincenzo Librandi_, Oct 16 2015 *)
%o (PARI) a(n) = if(n==1, 1, (1 + (-1)^n + (1-I)*(-I)^n + (1+I)*I^n + 2*n) / 4); \\ _Colin Barker_, Oct 15 2015
%o (PARI) Vec(x*(x^5-2*x^4+x^3+x^2+1) / ((x-1)^2*(x+1)*(x^2+1)) + O(x^100)) \\ _Colin Barker_, Oct 15 2015
%Y See A187180-A187188 for alphabets of size 2 through 10.
%Y See also A109337, A187199, A187200, A106249, A083219, A018837.
%K nonn,easy
%O 1,3
%A _N. J. A. Sloane_, Mar 06 2011