OFFSET
1,1
COMMENTS
a(n) is the number of solutions to Sum_{i=1..n} x_i^2 == 1 (mod 3).
LINKS
Jianing Song, Table of n, a(n) for n = 1..500
Index entries for linear recurrences with constant coefficients, signature (3,-3,9).
FORMULA
a(n) = middle term in M^n * [1, 0, 0]^T, where M = the 3 X 3 matrix [1, 0, 2 / 2, 1, 0 / 0, 2, 1]] and T denotes transpose. [Edited by Petros Hadjicostas, Dec 19 2019]
O.g.f.: 2*x*(1 - x)/((1 - 3*x)*(1 + 3*x^2)).
E.g.f.: 1/3*(exp(3*x) + 2*cos(sqrt(3)*x - 2*Pi/3)).
a(n) = 3^(n/2 - 1)*((-i)^n*(-1 + sqrt(3)*i)/2 + i^n*(-1 - sqrt(3)*i)/2 + 3^(n/2)), where i is the imaginary unit.
a(n) = 3^(n/2 - 1)*(2*cos(n*Pi/2 - 2*Pi/3) + 3^(n/2)).
a(n) = 3^(n-1) + (-3)^(n/2-1) for even n and 3^(n-1) + (-3)^((n-1)/2) for odd n.
a(n) = a(n-1) + 2*A101990(n-1).
EXAMPLE
a(5) = 90 since M^5 * [1, 0, 0]^T = [81, 90, 72]^T.
MATHEMATICA
LinearRecurrence[{3, -3, 9}, {2, 4, 6}, 30] (* Jianing Song, Sep 05 2018 *)
PROG
(PARI) Vec(2*x*(1-x)/((1-3*x)*(1+3*x^2)) + O(x^40))
(PARI) a(n) = ([1, 0, 2 ; 2, 1, 0 ; 0, 2, 1]^n*mattranspose([1, 0, 0]))[2]; \\ Michel Marcus, Dec 20 2019
(Magma) I:=[2, 4, 6]; [n le 3 select I[n] else 3*Self(n-1)-3*Self(n-2)+9*Self(n-3): n in [1..30]]; // Jianing Song, Sep 05 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jianing Song, Sep 02 2018
STATUS
approved