OFFSET
1,3
LINKS
Ray Chandler, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,0,0,1,-1).
FORMULA
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.
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), ...
From Colin Barker, Oct 15 2015: (Start)
a(n) = (1+(-1)^n+(1-i)*(-i)^n+(1+i)*i^n+2*n)/4 for n>1, where i = sqrt(-1).
G.f.: x*(x^5-2*x^4+x^3+x^2+1) / ((x-1)^2*(x+1)*(x^2+1)).
From Wesley Ivan Hurt, May 03 2021: (Start)
a(n) = a(n-1)+a(n-4)-a(n-5).
a(n) = floor((n+1+(-1)^floor((n+1)/2))/2) for n > 1. (End)
EXAMPLE
The sequence begins
1 1
2 3 2 3
4 5 4 5
6 7 6 7
8 9 8 9
10 11 10 11 ...
MAPLE
1, 1, seq(op(2*i*[1, 1, 1, 1]+[0, 1, 0, 1]), i=1..100); # Robert Israel, Oct 15 2015
MATHEMATICA
Join[{1}, LinearRecurrence[{1, 0, 0, 1, -1}, {1, 2, 3, 2, 3}, 119]] (* Ray Chandler, Aug 26 2015 *)
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 *)
PROG
(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
(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Mar 06 2011
STATUS
approved