A087204 Period 6: repeat [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, 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, 1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1
Offset: 0
Examples
a(2) = -1 = a(1) - a(0) = 1 - 2 = ((1+sqrt(-3))/2)^2 + ((1-sqrt(-3))/2)^2 = -1 = -2/4 + 2*sqrt(-3)/4 - 2/4 -2 sqrt(-3)/4 = -1. G.f. = 2 + x - x^2 - 2*x^3 - x^4 + x^5 + 2*x^6 + x^7 - x^8 - 2*x^9 - x^10 + ...
References
- A. T. Benjamin and J. J. Quinn, Proofs that really count: the art of combinatorial proof, M.A.A. 2003, id. 176.
- Paulo Ribenboim, My Numbers, My Friends: Popular Lectures on Number Theory, Springer-Verlag, NY, 2000, p. 6.
Links
- Tanya Khovanova, Recursive Sequences.
- Wikipedia, Lucas sequence.
- Index entries for linear recurrences with constant coefficients, signature (1,-1).
- Index entries for recurrences a(n) = k*a(n - 1) +/- a(n - 2).
Programs
-
Magma
&cat[[2, 1, -1, -2, -1, 1]^^20]; // Wesley Ivan Hurt, Jun 19 2016
-
Maple
A087204:=n->[2, 1, -1, -2, -1, 1][(n mod 6)+1]: seq(A087204(n), n=0..100); # Wesley Ivan Hurt, Jun 19 2016
-
Mathematica
PadLeft[{}, 108, {2,1,-1,-2,-1,1}] (* Harvey P. Dale, Sep 11 2011 *) a[ n_] := {1, -1, -2, -1, 1, 2}[[Mod[n, 6, 1]]]; (* Michael Somos, Jan 29 2015 *) a[ n_] := 2 Re[ Exp[ Pi I n / 3]]; (* Michael Somos, Mar 29 2015 *)
-
PARI
{a(n) = [2, 1, -1, -2, -1, 1][n%6 + 1]}; /* Michael Somos, Oct 22 2006 */
-
PARI
A087204(n) = if(0==n, 2, my(f = factor(n)); prod(k=1, #f~, if(f[k, 1]<=3, 1-f[k, 1], 1))); \\ (After David W. Wilson's multiplicative formula) - Antti Karttunen, Apr 28 2022
-
Sage
[lucas_number2(n,1,1) for n in range(0, 102)] # Zerinvary Lajos, Apr 30 2009
Formula
a(n) = a(n-1) - a(n-2), starting with a(0) = 2 and a(1) = 1.
G.f.: (2-x)/(1-x+x^2).
a(n) = Sum_{k>=0} (-1)^k*n/(n-k)*C(n-k, k).
a(n) = (1/2)*((-1)^floor(n/3) + 2*(-1)^floor((n+1)/3) + (-1)^floor((n+2)/3)).
Multiplicative with a(2^e) = -1, a(3^e) = -2, a(p^e) = 1 otherwise. - David W. Wilson, Jun 12 2005
a(n) = a(-n) = -a(n-3) for all n in Z. - Michael Somos, Oct 22 2006
E.g.f.: 2*exp(x/2)*cos(sqrt(3)*x/2). - Sergei N. Gladkovskii, Aug 12 2012
a(n) = r^n + s^n, with r=(1+i*sqrt(3))/2 and s=(1-i*sqrt(3))/2 the roots of 1-x+x^2. - Ralf Stephan, Jul 19 2013
a(n) = 2*cos(n*Pi/3). - Wesley Ivan Hurt, Jun 19 2016
Dirichlet g.f.: zeta(s)*(1-2^(1-s)-3^(1-s)+6^(1-s)). - Amiram Eldar, Jan 01 2023
Extensions
Edited by Ralf Stephan, Feb 04 2005
Comments