OFFSET
0,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..5000
Michael Somos, Rational Function Multiplicative Coefficients
Index entries for linear recurrences with constant coefficients, signature (0, -1, 0, -1).
FORMULA
Euler transform of length 6 sequence [2, -2, 0, -1, 0, 1].
a(n) = 2*b(n) where b(n) is multiplicative with b(2^e) = -(-1)^e / 2 if e>0, b(3^e) = 0^e, b(p^e) = 1 if p == 1 (mod 6), b(p^e) = (-1)^e if p == 5 (mod 6).
G.f.: (1 - x^2)^2 * (1 - x^4) / ((1 - x)^2 * (1 - x^6)) = (1 + x)^2 * (1 + x^2) / ((1 - x + x^2) * (1 + x + x^2)).
a(3*n) = 0 unless n = 0. a(-n) = -a(n) unless n = 0. a(n + 6) = a(n) unless n = 0.
EXAMPLE
G.f. = 1 + 2*x + x^2 - x^4 - 2*x^5 + 2*x^7 + x^8 - x^10 - 2*x^11 + 2*x^13 + ...
MATHEMATICA
a[ n_] := Boole[n == 0] + {0, 2, 1, 0, -1, 2} [[ Mod[n, 6] + 1]]
CoefficientList[Series[(1-x^2)^2*(1-x^4)/((1-x)^2*(1-x^6)), {x, 0, 50}], x] (* G. C. Greubel, Aug 13 2018 *)
PROG
(PARI) {a(n) = (n==0) + [0, 2, 1, 0, -1, -2][n%6 + 1]}
(PARI) {a(n) = my(A, p, e); if( n==0, 1, A = factor(n); 2 * sign(n) * prod( k=1, matsize(A)[1], if( p = A[k, 1], e = A[k, 2]; if( p==2, -(-1)^e / 2, if( p==3, 0, if( p%6==1, 1, (-1)^e))))))}
(Magma) m:=50; R<x>:=PowerSeriesRing(Integers(), m); Coefficients(R!((1-x^2)^2*(1-x^4)/((1-x)^2*(1-x^6)))); // _G. c. Greubel_, Aug 13 2018
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Michael Somos, Aug 02 2011
STATUS
approved