OFFSET
0,5
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (0,0,2,0,0,-1).
FORMULA
a(n) = (2/3)*(floor(n/3)+1)*(1-cos(2*Pi*n/3)).
G.f.: x*(1 + x)/(1 - x^3)^2. - Arkadiusz Wesolowski, May 28 2013
a(n) = sin(n*Pi/3)*((4n+6)*sin(n*Pi/3)-sqrt(3)*cos(n*Pi))/9. - Wesley Ivan Hurt, Sep 24 2017
EXAMPLE
a(4) = 2 because k=1 and k=4 satisfy the equation.
MATHEMATICA
LinearRecurrence[{0, 0, 2, 0, 0, -1}, {0, 1, 1, 0, 2, 2}, 100] (* Vincenzo Librandi, Sep 22 2015 *)
Table[PadRight[{0}, 3, n], {n, 30}]//Flatten (* Harvey P. Dale, Jan 27 2021 *)
PROG
(PARI) concat(0, Vec((1+x)/(1-x^3)^2 +O(x^99))) \\ Charles R Greathouse IV, Oct 24 2014
(PARI) a(n) = sum(k=0, n, Mod(k*n, 3)==1); \\ Michel Marcus, Sep 27 2017
(Magma) I:=[0, 1, 1, 0, 2, 2]; [n le 6 select I[n] else 2*Self(n-3) - Self(n-6): n in [1..100]]; // Vincenzo Librandi, Sep 22 2015
(SageMath)
@CachedFunction
def A087508(n):
if (n<6): return (0, 1, 1, 0, 2, 2)[n]
[A087508(n) for n in (0..100)] # G. C. Greubel, Sep 02 2022
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Paul Barry, Sep 11 2003
STATUS
approved