%I #118 Jul 25 2024 14:35:53
%S 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,
%T 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,
%U 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
%N a(n) = n mod 3.
%C Fixed point of morphism 0 -> 01, 1 -> 20, 2 -> 12.
%C Complement of A002264, since 3*A002264(n) + a(n) = n. - _Hieronymus Fischer_, Jun 01 2007
%C Decimal expansion of 4/333. - _Elmo R. Oliveira_, Feb 19 2024
%C Period 3: repeat [0, 1, 2]. - _Elmo R. Oliveira_, Jun 20 2024
%H Paul Barry, <a href="https://arxiv.org/abs/2004.04577">On a Central Transform of Integer Sequences</a>, arXiv:2004.04577 [math.CO], 2020.
%H Ralph E. Griswold, <a href="https://www2.cs.arizona.edu/patterns/sequences/">Shaft Sequences</a>
%H Ralph E. Griswold, <a href="https://web.archive.org/web/20090215102330/http://www.cs.arizona.edu/patterns/sequences/index.html">Shaft Sequences</a> [From the Wayback machine]
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,1).
%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>
%F a(n) = n - 3*floor(n/3) = a(n-3).
%F G.f.: (2*x^2+x)/(1-x^3). - Mario Catalani (mario.catalani(AT)unito.it), Jan 08 2003
%F From _Hieronymus Fischer_, May 29 2007: (Start)
%F a(n) = 1 + (1-2*cos(2*Pi*(n-1)/3)) * sin(2*Pi*(n-1)/3)) / sqrt(3).
%F 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)
%F From _Hieronymus Fischer_, Jun 01 2007: (Start)
%F a(n) = (16/9)*((sin(Pi*(n-2)/3))^2+2*(sin(Pi*(n-1)/3))^2)*(sin(Pi*n/3))^2.
%F a(n) = (4/3)*(|sin(Pi*(n-2)/3)|+2*|sin(Pi*(n-1)/3)|)*|sin(Pi*n/3)|.
%F 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)
%F a(n) = 3 - a(n-1) - a(n-2) for n > 1. - _Reinhard Zumkeller_, Apr 13 2008
%F a(n) = 1-2*sin(4*Pi*(n+2)/3)/sqrt(3). - _Jaume Oliver Lafont_, Dec 05 2008
%F From _Wesley Ivan Hurt_, May 27 2015, Mar 22 2016: (Start)
%F a(n) = 1 - 0^((-1)^(n/3)-(-1)^n) + 0^((-1)^((n+1)/3)+(-1)^n).
%F 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.
%F a(n) = 1 + 2*cos(Pi*(2*n+4)/3)/3 + 4*cos(Pi*(2*n+2)/3)/3. (End)
%F a(n) = (r^n*(r-1) - r^(2*n)*(r + 2) + 3)/3 where r = (-1 + sqrt(-3))/2. - _Guenther Schrack_, Sep 23 2019
%F 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
%F a(n) = A010882(n) - 1 = A131555(2*n) = A131555(2*n+1). - _Elmo R. Oliveira_, Jun 25 2024
%e G.f. = x + 2*x^2 + x^4 + 2*x^5 + x^7 + 2*x^8 + x^10 + 2*x^11 + x^13 + ...
%p A010872:=n->(n mod 3): seq(A010872(n), n=0..100); # _Wesley Ivan Hurt_, May 27 2015
%t Nest[ Function[ l, {Flatten[(l /. {0 -> {0, 1}, 1 -> {2, 0}, 2 -> {1, 2}})]}], {0}, 7] (* _Robert G. Wilson v_, Feb 28 2005 *)
%o (Haskell)
%o a010872 = (`mod` 3)
%o a010872_list = cycle [0,1,2] -- _Reinhard Zumkeller_, May 26 2012
%o (Magma) [n mod 3 : n in [0..100]]; // _Wesley Ivan Hurt_, May 27 2015
%o (PARI) x='x+O('x^200); concat(0, Vec((2*x^2+x)/(1-x^3))) \\ _Altug Alkan_, Mar 23 2016
%Y Cf. A000035, A002264, A002265, A002266, A004526, A010873, A080425, A102283.
%Y Cf. A010882, A130481 (partial sums), A131555.
%Y Other related sequences are A130482, A130483, A130484, A130485.
%K easy,nonn
%O 0,3
%A _N. J. A. Sloane_
%E Edited by _Joerg Arndt_, Apr 21 2014