%I #152 Jan 05 2025 19:51:36
%S 1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,
%T -2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,
%U 1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2
%N Period 3: repeat [1, 1, -2].
%C WARNING: It is unclear whether this sequence should start at offset 1 (as written) or offset 0 (in analogy to many similar sequences, which seems to be assumed in many of the given formulas).
%C Inverse binomial transform of A057079. - _Paul Barry_, May 15 2003
%C The unsigned version, with g.f. (1 + x + 2*x^2)/(1 - x^3), has a(n) = 4/3 -cos(2*Pi*n/3)/3 - sqrt(3)*sin(2*Pi*n/3)/3 = gcd(Fib(n+4), Fib(n+1)). - _Paul Barry_, Apr 02 2004
%C a(n) = L(n-2,-1), where L is defined as in A108299; see also A010892 for L(n,+1). - _Reinhard Zumkeller_, Jun 01 2005
%C From the Taylor expansion of log(1 + x + x^2) at x = 1, Sum_{k > 0} a(k)/k = log(3) = A002391. This is case n = 3 of the general expression Sum_{k > 0} (1-n*!(k mod n))/k = log(n). - _Jaume Oliver Lafont_, Oct 16 2009
%C If used with offset zero, a non-simple continued fraction representation of 2+sqrt(2). - _R. J. Mathar_, Mar 08 2012
%C Periodic sequences of this type can be also calculated by a(n) = c + floor(q/(p^m-1)*p^n) mod p, where c is a constant, q is the number representing the periodic digit pattern and m is the period length. c, p and q can be calculated as follows: Let D be the array representing the number pattern to be repeated, m = size of D, max = maximum value of elements in D, min = minimum value of elements in D. Than c := min, p := max - min + 1 and q := p^m*Sum_{i=1..m} (D(i)-min)/p^i. Example: D = (1, 1, -2), c = -2, p = 4 and q = 60 for this sequence. - _Hieronymus Fischer_, Jan 04 2013
%C This is the Dirichlet inverse of A117997. - _Petros Hadjicostas_, Jul 25 2020
%H W. Florek, <a href="http://doi.org/10.1016/j.amc.2018.06.014">A class of generalized Tribonacci sequences applied to counting problems</a>, Appl. Math. Comput., 338 (2018), 809-821.
%H Ralph E. Griswold, <a href="https://www2.cs.arizona.edu/patterns/sequences/">Shaft Sequences</a>, 2001 (see also <a href="https://web.archive.org/web/20131022221920/http://www.cs.arizona.edu/patterns/sequences.html">here</a>).
%H Tanya Khovanova, <a href="http://www.tanyakhovanova.com/RecursiveSequences/RecursiveSequences.html">Recursive Sequences</a>.
%H W. O. J. Moser, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/31-1/moser.pdf">Cyclic binary strings without long runs of like (alternating) bits</a>, Fibonacci Quart. 31(1) (1993), 2-6.
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (-1,-1).
%F With offset zero, a(n) = A057079(2n). a(n) = -a(n-1) - a(n-2) with a(0) = a(1) = 1.
%F From Mario Catalani (mario.catalani(AT)unito.it), Jan 07 2003: (Start)
%F G.f.: x*(1 + 2*x)/(1 + x + x^2).
%F a(n) = (-1)^floor(2n/3) + ((-1)^floor((2n-1)/3) + (-1)^floor((2n+1)/3))/2. (End)
%F a(n) = -2*cos(2*Pi*n/3). - _Jaume Oliver Lafont_, May 06 2008
%F Dirichlet g.f.: zeta(s)*(1-1/3^(s-1)). - _R. J. Mathar_, Feb 09 2011
%F a(n) = n * Sum_{k=1..n} binomial(k,n-k)/k*(-1)^(k+1). - _Dmitry Kruchinin_, Jun 03 2011
%F a(n) = -2 + floor(110/333*10^(n+1)) mod 10. - _Hieronymus Fischer_, Jan 04 2013
%F a(n) = -2 + floor(20/21*4^(n+1)) mod 4. - _Hieronymus Fischer_, Jan 04 2013
%F a(n) = a(n-3) for n > 3. - _Wesley Ivan Hurt_, Jul 01 2016
%F E.g.f.: 2 - 2*cos(sqrt(3)*x/2)*exp(-x/2). - _Ilya Gutkovskiy_, Jul 01 2016
%F a(n) = (-1)^n*hypergeom([-n/2-1, -n/2-3/2], [-n-2], 4). - _Peter Luschny_, Dec 17 2016
%F a(n) = A000032(n) - A007040(n), for n > 1. - _Wojciech Florek_, Feb 20 2018
%e G.f.: x + x^2 - 2*x^3 + x^4 + x^5 - 2*x^6 + x^7 + x^8 - 2*x^9 + ... - _Michael Somos_, Nov 27 2019
%p seq(op([1, 1, -2]), n=1..50); # _Wesley Ivan Hurt_, Jul 01 2016
%t a[n_] := {1, 1, -2}[[Mod[n - 1, 3] + 1]]; Table[a[n], {n, 108}] (* _Jean-François Alcover_, Jul 19 2013 *)
%t PadRight[{}, 90, {1, 1, -2}] (* After Harvey P. Dale, or *)
%t CoefficientList[ Series[(2x + 1)/(x^2 + x + 1), {x, 0, 89}], x] (* or *)
%t LinearRecurrence[{-1, -1}, {1, 1}, 90] (* _Robert G. Wilson v_, Jul 30 2018 *)
%o (PARI) a(n)=1-3*!(n%3) \\ _Jaume Oliver Lafont_, Oct 16 2009
%o (Sage)
%o def A061347():
%o x, y = -1, -1
%o while True:
%o yield -x
%o x, y = y, -x -y
%o a = A061347(); [next(a) for i in range(40)] # _Peter Luschny_, Jul 11 2013
%o (Magma) &cat [[1, 1, -2]^^30]; // _Wesley Ivan Hurt_, Jul 01 2016
%o (GAP) Flat(List([1..50],n->[1,1,-2])); # _Muniru A Asiru_, Aug 02 2018
%Y Apart from signs, same as A057079 (also bin. Transf), A100063. Cf. A000045, A010892 for the rules a(n) = a(n - 1) + a(n - 2), a(n) = a(n - 1) - a(n - 2). a(n) = - a(n - 1) + a(n - 2) gives a signed version of Fibonacci numbers.
%Y Alternating row sums of A130777: repeat(1,-2,1).
%Y Cf. A000032, A002391, A007040, A100886, A108299, A117997, A320769.
%K sign,easy,mult
%O 1,3
%A _Jason Earls_, Jun 07 2001
%E Better definition from _M. F. Hasler_, Jan 13 2013