OFFSET
0,3
COMMENTS
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (0,1,0,1,0,-1).
FORMULA
a(n+1) = (A186421(n)=0,1,2,1,4,...) + 1.
a(2*n) = A052928(n+1).
a(n+2) - a(n) = 2, 2, 0, 2. (period 4).
a(n) = a(n-2) +a(n-4) -a(n-6); also holds for A215495(n).
G.f.: x*(1+2*x+2*x^2+x^4) / ( (x^2+1)*(x-1)^2*(1+x)^2 ). - R. J. Mathar, Aug 21 2012
a(n) = (1/4)*((1 +(-1)^n)*(1 - (-1)^floor(n/2)) + (3 -(-1)^n)*n). - G. C. Greubel, Apr 25 2018
MATHEMATICA
a[n_] := (1/4)*((-(1 + (-1)^n))*(-1 + (-1)^Floor[n/2]) - (-3 + (-1)^n)*n ); Table[a[n], {n, 0, 84}] (* Jean-François Alcover, Sep 18 2012 *)
LinearRecurrence[{0, 1, 0, 1, 0, -1}, {0, 1, 2, 3, 2, 5}, 80] (* Harvey P. Dale, May 29 2016 *)
PROG
(PARI) A212831(n)=if(bittest(n, 0), n, n\2+bittest(n, 1)) \\ M. F. Hasler, Oct 21 2012
(PARI) for(n=0, 50, print1((1/4)*((1 +(-1)^n)*(1 - (-1)^floor(n/2)) + (3 -(-1)^n)*n), ", ")) \\ G. C. Greubel, Apr 25 2018
(Magma) [(1/4)*((1 +(-1)^n)*(1 - (-1)^Floor(n/2)) + (3 -(-1)^n)*n): n in [0..50]]; // G. C. Greubel, Apr 25 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Paul Curtz, Aug 14 2012
EXTENSIONS
Corrected and edited by M. F. Hasler, Oct 21 2012
STATUS
approved