%I #25 Apr 19 2023 00:35:14
%S 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,
%T -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,-2,
%U 1,-2,1,-2,1,-2,1,-2,1,-2,1,-2,1,-2,1,-2,1,-2,1,-2
%N Period 2: repeat [1, -2].
%H Michael Somos, <a href="http://grail.eecs.csuohio.edu/~somos/rfmc.html">Rational Function Multiplicative Coefficients</a>.
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,1).
%F G.f.: x * (1 - 2*x) / (1 - x^2) = x / (1 + 2*x / (1 - 3*x / (2 - x))).
%F E.g.f.: (exp(x) - 1)*(3/exp(x) - 1)/2.
%F a(n) is multiplicative with a(2^e) = -2 if e>0, a(p^e) = 1 otherwise.
%F Moebius transform is length 2 sequence [1, -3].
%F a(n) = -(1 + 3*(-1)^n)/2 if n>=1.
%F a(2*n) = -2, a(2*n + 1) = 1, a(0) = 0.
%F a(n) = -(-1)^n * A134451(n) for all n in Z.
%F a(n) = a(n+2) = -(-1)^n * A000034(n-1) = -A168361(n+1) for n>=1.
%F Dirichlet g.f.: zeta(s)*(1-3/2^s). - _Amiram Eldar_, Jan 03 2023
%e G.f. = x - 2*x^2 + x^3 - 2*x^4 + x^5 - 2*x^6 + x^7 - 2*x^8 + ...
%t a[ n_] := If[ n < 1, 0, -2 + 3 Mod[n, 2]];
%t a[ n_] := Which[ n < 1, 0, OddQ[n], 1, True, -2];
%t a[ n_] := SeriesCoefficient[ (x - 2*x^2) / (1 - x^2), {x, 0, n}];
%t PadRight[{}, 100, {1, -2}] (* _Vincenzo Librandi_, Feb 29 2020 *)
%o (PARI) {a(n) = if( n<1, 0, -(1 + 3*(-1)^n)/2)};
%o (PARI) {a(n) = if( n<1, 0, -2 + 3*(n%2))};
%o (PARI) {a(n) = if( n<1, 0, [-2, 1][n%2 + 1])};
%o (PARI) {a(n) = if( n<0, 0, polcoeff( (x - 2*x^2) / (1 - x^2) + x * O(x^n), n))};
%o (Magma) &cat [[1, -2]^^50]; // _Vincenzo Librandi_, Feb 29 2020
%Y Cf. A000034, A040001, A134451, A168361, A280193.
%K sign,mult,easy
%O 1,2
%A _Michael Somos_, Sep 24 2019