%I #58 Sep 08 2022 08:44:53
%S 1,1,2,2,2,0,0,0,2,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,0,0,
%T 0,1,1,1,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
%U 0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,0,0,0,1,1,1,2,2,2,0,0,0,0,0,0,0,0,0,0
%N An example of a d-perfect sequence: a(n) = Catalan(n) mod 3.
%C This is A006996 with all its terms repeated three times, except the initial term only twice. A006996 is a fixed point of the morphism 0 -> 000, 1 -> 120, 2 -> 210. [The original comment edited by _Antti Karttunen_, Aug 14 2017]
%C Equals Catalan(n) mod 3. (Cf. A000108.) - _Paul D. Hanna_, Jun 20 2003 [confirmed by _Christian G. Bower_, Jun 12 2005]
%C Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!).
%H Antti Karttunen, <a href="/A039969/b039969.txt">Table of n, a(n) for n = 0..10000</a>
%H Rob Burns, <a href="https://arxiv.org/abs/1611.03705">Asymptotic density of Catalan numbers modulo 3 and powers of 2</a>, arXiv:1611.03705 [math.NT], 2016.
%H David Kohel, San Ling and Chaoping Xing, <a href="https://doi.org/10.1007/978-1-4471-0551-0_23">Explicit Sequence Expansions</a>, in: C. Ding, T. Helleseth and H. Niederreiter (eds.), Sequences and their Applications, Proceedings of SETA'98 (Singapore, 1998), Discrete Mathematics and Theoretical Computer Science, 1999, pp. 308-317; <a href="http://www.maths.usyd.edu.au/u/kohel/doc/perfect.ps">alternative link</a>.
%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>
%F a(n) = ((-1)^(n+1)*A001006(n-1)) mod 3, for n>0. - _Christian G. Bower_, Jun 12 2005
%F a(n) = a(n-1) if n == 0 or 1 (mod 3). a(n) = 0 if n == 5,6, or 7 (mod 9). - _Robert Israel_, Sep 20 2015
%F a(3n) = A006996(n). - _Antti Karttunen_, Aug 14 2017
%F Asymptotic mean: lim_{n->oo} (1/n) Sum_{k=1..n} a(k) = 0 (Burns, 2016). - _Amiram Eldar_, Jan 26 2021
%p seq(binomial(2*n, n)/(n+1) mod 3, n = 0 .. 100); # _Robert Israel_, Sep 20 2015
%t Take[ Flatten[ Nest[ Flatten[ # /. {1 -> {1, 2, 0}, 2 -> {2, 1, 0}, 0 -> {0, 0, 0}}] &, {1}, 4] /. {1 -> {1, 1, 1}, 2 -> {2, 2, 2}, 0 -> {0, 0, 0}}], {2, 106}] (* or *)
%t Table[ Mod[ Binomial[ 2n, n]/(n + 1), 3], {n, 0, 104}] (* _Robert G. Wilson v_, Sep 09 2005 *)
%t Mod[CatalanNumber[Range[0,110]],3] (* _Harvey P. Dale_, Oct 23 2017 *)
%o (Magma) [Catalan(n) mod 3: n in [1..80]]; // _Vincenzo Librandi_, Jul 14 2015
%o (PARI) A039969(n) = ((binomial(2*n, n)/(n+1))%3); \\ _Antti Karttunen_, Aug 13 2017
%Y Cf. A000108, A001006, A010872, A039972, A067397.
%Y Cf. A006996 (trisection).
%K nonn
%O 0,3
%A _N. J. A. Sloane_
%E More terms from _Christian G. Bower_, Jun 12 2005
%E Offset corrected from 1 to 0 by _Antti Karttunen_, Aug 13 2017