OFFSET
0,6
LINKS
Index entries for linear recurrences with constant coefficients, signature (0,0,2,0,0,-1).
FORMULA
a(n) = Sum_{k=0..n} [(k*n) == 2 (mod 3)];
a(n) = n - 2*(floor(n/3) + 1)*(1 - cos(2*Pi*n/3))/3 - floor(n/3)*(5 + 4*cos(2*Pi*n/3))/3.
G.f.: x^2*(x^2+1) / ((x-1)^2*(x^2+x+1)^2). - Colin Barker, Mar 31 2013
a(n) = 2*sin(n*Pi/3)*(sqrt(3)*cos(n*Pi) + 2*n*sin(n*Pi/3))/9. - Wesley Ivan Hurt, Sep 24 2017
EXAMPLE
a(8) = #{1,4,7} = 3.
MATHEMATICA
{#-1, 1+#, 0}[[Mod[#, 3, 1]]]/3&/@Range[0, 99] (* Federico Provvedi, Jun 15 2021 *)
LinearRecurrence[{0, 0, 2, 0, 0, -1}, {0, 0, 1, 0, 1, 2}, 100] (* Harvey P. Dale, May 04 2023 *)
PROG
(PARI) a(n) = sum(k=0, n, (k*n % 3)==2); \\ Michel Marcus, Sep 25 2017
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Paul Barry, Sep 11 2003
STATUS
approved