%I #10 Sep 08 2022 08:46:18
%S 1,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,
%T -1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,
%U 2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2
%N a(2*n) = 2, a(2*n + 1) = -1, a(0) = 1.
%H G. C. Greubel, <a href="/A280193/b280193.txt">Table of n, a(n) for n = 0..5000</a>
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,1).
%F Euler transform of length 6 sequence [-1, 2, 1, 0, 0, -1].
%F Moebius transform is length 2 sequence [-1, 3].
%F a(n) = -b(n) where b() is multiplicative with b(2^e) = -2 if e>0, b(p^e) = 1 otherwise.
%F G.f.: (1 - x + x^2) / (1 - x^2).
%F G.f.: (1 - x) * (1 - x^6) / ((1 - x^3) * (1 -x^2)^2).
%F G.f.: 1 / (1 + x / (1 + x / (1 - 3*x / (1 + x)))).
%F a(n) = (-1)^n * A040001(n).
%F A028242(n) = Sum_{k=0..n} a(k).
%F A117575(n+1) = Product_{k=0..n} a(k).
%F A000225(n-1) = Sum_{k=0..n} binomial(n, k) * a(k) if n>0.
%F A000325(n) = Sum_{k=0..n} binomial(n, k+1) * a(k) if n>0.
%F a(n) = Sum_{k=0..n} binomial(n, k) * (-1)^k * A083329(k).
%F A079583(n) = p(-1) where p(x) is the unique degree-n polynomial such that p(k) = a(k) for k = 0, 1, ..., n.
%F a(n) = A168361(n+1), n>0. - _R. J. Mathar_, Jan 04 2017
%e G.f. = 1 - x + 2*x^2 - x^3 + 2*x^4 - x^5 + 2*x^6 - x^7 + 2*x^8 - x^9 + ...
%t a[ n_] := Which[ n < 1, Boole[n == 0], OddQ[n], -1, True, 2];
%t a[ n_] := SeriesCoefficient[ (1 - x + x^2) / (1 - x^2), {x, 0, n}];
%o (PARI) {a(n) = if( n<1, n==0, 2 - 3*(n%2))};
%o (PARI) {a(n) = if( n<1, n==0, [2, -1][n%2 + 1])};
%o (PARI) {a(n) = if( n<0, 0, polcoeff( (1 - x + x^2) / (1 - x^2) + x * O(x^n), n))};
%o (Magma) m:=50; R<x>:=PowerSeriesRing(Integers(), m); Coefficients(R!((1 - x+x^2)/(1-x^2))); // _G. C. Greubel_, Jul 29 2018
%Y Cf. A000225, A000325, A040001, A028242, A079583, A083329, A117575.
%K sign,easy
%O 0,3
%A _Michael Somos_, Dec 28 2016