cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A010872 a(n) = n mod 3.

Original entry on oeis.org

0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2
Offset: 0

Views

Author

Keywords

Comments

Fixed point of morphism 0 -> 01, 1 -> 20, 2 -> 12.
Complement of A002264, since 3*A002264(n) + a(n) = n. - Hieronymus Fischer, Jun 01 2007
Decimal expansion of 4/333. - Elmo R. Oliveira, Feb 19 2024
Period 3: repeat [0, 1, 2]. - Elmo R. Oliveira, Jun 20 2024

Examples

			G.f. = x + 2*x^2 + x^4 + 2*x^5 + x^7 + 2*x^8 + x^10 + 2*x^11 + x^13 + ...
		

Crossrefs

Cf. A010882, A130481 (partial sums), A131555.
Other related sequences are A130482, A130483, A130484, A130485.

Programs

  • Haskell
    a010872 = (`mod` 3)
    a010872_list = cycle [0,1,2]  -- Reinhard Zumkeller, May 26 2012
    
  • Magma
    [n mod 3 : n in [0..100]]; // Wesley Ivan Hurt, May 27 2015
    
  • Maple
    A010872:=n->(n mod 3): seq(A010872(n), n=0..100); # Wesley Ivan Hurt, May 27 2015
  • Mathematica
    Nest[ Function[ l, {Flatten[(l /. {0 -> {0, 1}, 1 -> {2, 0}, 2 -> {1, 2}})]}], {0}, 7] (* Robert G. Wilson v, Feb 28 2005 *)
    PadRight[{},120,{0,1,2}] (* or *) Mod[Range[0,120],3] (* Harvey P. Dale, Jul 20 2025 *)
  • PARI
    my(x='x+O('x^200)); concat(0, Vec((2*x^2+x)/(1-x^3))) \\ Altug Alkan, Mar 23 2016

Formula

a(n) = n - 3*floor(n/3) = a(n-3).
G.f.: (2*x^2+x)/(1-x^3). - Mario Catalani (mario.catalani(AT)unito.it), Jan 08 2003
From Hieronymus Fischer, May 29 2007: (Start)
a(n) = 1 + (1-2*cos(2*Pi*(n-1)/3)) * sin(2*Pi*(n-1)/3) / sqrt(3).
a(n) = (1-r^n)*(1+r^n/(1-r)) where r=exp(2*Pi*i/3)=(-1+sqrt(3)*i)/2 and i=sqrt(-1). [corrected by Guenther Schrack, Sep 23 2019] (End)
From Hieronymus Fischer, Jun 01 2007: (Start)
a(n) = (16/9)*((sin(Pi*(n-2)/3))^2+2*(sin(Pi*(n-1)/3))^2)*(sin(Pi*n/3))^2.
a(n) = (4/3)*(|sin(Pi*(n-2)/3)|+2*|sin(Pi*(n-1)/3)|)*|sin(Pi*n/3)|.
a(n) = (4/9)*((1-cos(2*Pi*(n-2)/3))+2*(1-cos(2*Pi*(n-1)/3)))*(1-cos(2*Pi*n/3)). (End)
a(n) = 3 - a(n-1) - a(n-2) for n > 1. - Reinhard Zumkeller, Apr 13 2008
a(n) = 1-2*sin(4*Pi*(n+2)/3)/sqrt(3). - Jaume Oliver Lafont, Dec 05 2008
From Wesley Ivan Hurt, May 27 2015, Mar 22 2016: (Start)
a(n) = 1 - 0^((-1)^(n/3)-(-1)^n) + 0^((-1)^((n+1)/3)+(-1)^n).
a(n) = 1 + (-1)^((2*n+4)/3)/3 + (-1)^((-2*n-4)/3)/3 + 2*(-1)^((2*n+2)/3)/3 + 2*(-1)^((-2*n-2)/3)/3.
a(n) = 1 + 2*cos(Pi*(2*n+4)/3)/3 + 4*cos(Pi*(2*n+2)/3)/3. (End)
a(n) = (r^n*(r-1) - r^(2*n)*(r + 2) + 3)/3 where r = (-1 + sqrt(-3))/2. - Guenther Schrack, Sep 23 2019
E.g.f.: exp(x) - exp(-x/2)*(cos(sqrt(3)*x/2) + sin(sqrt(3)*x/2)/sqrt(3)). - Stefano Spezia, Mar 01 2020
a(n) = A010882(n) - 1 = A131555(2*n) = A131555(2*n+1). - Elmo R. Oliveira, Jun 25 2024
From Nicolas Bělohoubek, May 26 2025: (Start)
a(n) = (3*a(n-1)+1)*(2-a(n-1))/2 for n > 0.
a(n) = (2*a(n-1)-4)/(3*a(n-1)-4) for n > 0. (End)

Extensions

Edited by Joerg Arndt, Apr 21 2014