OFFSET
0,4
COMMENTS
A permutation of A004526 (n > 0).
0 is at its own place. Distance between the two (2*k+1)'s: 2*k+1 terms. 0 is in position 0, the first 1 in position 1, the second 1 in position 2, the first 2 in position 4, the second 2 in position 8. Hence, r(n) = 0, 1, 2, 4, 8, 3, 6, 12, 16, 5, 10, 20, 24, ..., a permutation of A001477. See A225055. The recurrence r(n) = r(n-4) + r(n-8) - r(n-12) is the same as for a(n).
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..5000
Index entries for linear recurrences with constant coefficients, signature (0,0,0,1,0,0,0,1,0,0,0,-1).
FORMULA
a(n) = 3*a(n-8) - 3*a(n-16) + a(n-24).
a(n+4) = a(n) + period 8: repeat [2, 4, 2, 4, 0, 4, 2, 4].
a(n+8) = a(n) + period 4: repeat [2, 8, 4, 8] (= 2 * A176895).
a(2n) = A212831(n).
a(n) = n*(1+floor((2-n)/4)+floor((n-2)/4))/2+n*(1+floor((1-n)/2)+floor((n-1)/2))+(-n-2+2*(-1)^(n/4))*(ceiling(n/4)-floor(n/4)-1)/4. - Wesley Ivan Hurt, Sep 14 2014
a(n) = a(n-4) + a(n-8) - a(n-12). - Charles R Greathouse IV, Sep 14 2014
G.f.: x*(x^10+x^9+3*x^8+4*x^6+2*x^5+4*x^4+2*x^3+3*x^2+x+1) / ((x-1)^2*(x+1)^2*(x^2+1)^2*(x^4+1)). - Colin Barker, Sep 15 2014
MAPLE
A246416:=n->n*(1+floor((2-n)/4)+floor((n-2)/4))/2+n*(1+floor((1-n)/2)+floor((n-1)/2))+(-n-2+2*(-1)^(n/4))*(ceil(n/4)-floor(n/4)-1)/4: seq(A246416(n), n=0..50); # Wesley Ivan Hurt, Sep 14 2014
MATHEMATICA
Table[n (1 + Floor[(2 - n)/4] + Floor[(n - 2)/4])/2 + n (1 + Floor[(1 - n)/2] + Floor[(n - 1)/2]) + (-n - 2 + 2 (-1)^(n/4)) (Ceiling[n/4] - Floor[n/4] - 1)/4, {n, 0, 50}] (* Wesley Ivan Hurt, Sep 14 2014 *)
a[n_] := Switch[Mod[n, 4], 0, n/4-(-1)^(n/4)/2+1/2, 1|3, n, 2, n/2]; Table[a[n], {n, 0, 64}] (* Jean-François Alcover, Oct 09 2014 *)
LinearRecurrence[{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1}, {0, 1, 1, 3, 2, 5, 3, 7, 2, 9, 5, 11}, 70] (* Harvey P. Dale, Mar 23 2015 *)
PROG
(PARI) a(n)=if(n%4, n/(2-n%2), if(n%8, 1, 0)+n/4) \\ Charles R Greathouse IV, Sep 14 2014
(MAGMA) I:=[0, 1, 1, 3, 2, 5, 3, 7, 2, 9, 5, 11, 4, 13, 7, 15, 4, 17, 9, 19, 6, 21, 11, 23]; [n le 24 select I[n] else 3*Self(n-8)-3*Self(n-16)+Self(n-24): n in [1..80]]; // Vincenzo Librandi, Oct 15 2014
CROSSREFS
KEYWORD
nonn,easy,less
AUTHOR
Paul Curtz, Sep 14 2014
STATUS
approved