%I #37 Oct 21 2021 09:55:46
%S 1,1,2,6,16,38,104,270,726,1960,5368,14736,40880,113828,318848,896670,
%T 2532160,7174050,20390552,58112088,166037248,475467916,1364393896,
%U 3922624800,11297181456,32588003000,94143178098,272342710380,788854912240,2287679084096,6641649422408,19302293185470
%N Number of ternary Lyndon words whose digits sum to 0 mod 3; also number of trace 0 irreducible polynomials over GF(3).
%C Also number of ternary Lyndon words of trace 0 over GF(3).
%H G. C. Greubel, <a href="/A046209/b046209.txt">Table of n, a(n) for n = 1..2000</a>
%H F. Ruskey, <a href="http://combos.org/TSlyndon">Number of q-ary Lyndon words with given trace mod q</a>
%H F. Ruskey, <a href="http://combos.org/Tpoly">Number of monic irreducible polynomials over GF(q) with given trace</a>
%H F. Ruskey, <a href="http://combos.org/TlyndonFk">Number of Lyndon words over GF(q) with given trace</a>
%H <a href="/index/Lu#Lyndon">Index entries for sequences related to Lyndon words</a>
%F a(n) = 1/(3*n) * sum(d divides n, gcd(d, 3)*mu(d)*3^(n/d) ).
%F a(n) = A053548(n) + A053560(n) + A053561(n). - _R. J. Mathar_, Oct 21 2021
%e a(4) = 6 = |{ 0012, 0021, 0111, 0102, 0222, 1122 }|.
%t a[n_] := 1/(3n) DivisorSum[n, GCD[#, 3]*MoebiusMu[#]*3^(n/#)&]; Array[a, 32] (* _Jean-François Alcover_, Dec 06 2015, adapted from PARI *)
%o (PARI) a(n) = 1/(3*n) * sumdiv(n, d, gcd(d, 3)*moebius(d)*3^(n/d) ); /* _Joerg Arndt_, Aug 17 2012 */
%Y Cf. A046211.
%K nonn
%O 1,3
%A _Frank Ruskey_, Dec 13 1999