%I #27 Sep 16 2020 05:06:12
%S 1,0,1,1,3,0,1,2,0,0,1,1,3,0,3,4,7,0,1,3,1,0,1,2,0,0,0,1,3,0,1,8,1,0,
%T 3,0,3,0,3,6,7,0,1,1,0,0,1,4,0,0,7,3,3,0,3,2,1,0,1,3,3,0,0,0,9,0,1,7,
%U 1,0,1,0,7,0,0,1,1,0,1,12,0,0,1,1,21,0,3,2,7,0,3
%N Number of octic primitive Dirichlet characters modulo n.
%C a(n) is the number of primitive Dirichlet characters modulo n such that all entries are 0 or a eighth-power root of unity (+-1, +-i, +-sqrt(2)/2 +- sqrt(2)/2*i, i = sqrt(-1)).
%C Mobius transform of A247257.
%H Jianing Song, <a href="/A329272/b329272.txt">Table of n, a(n) for n = 1..65539</a>
%F Multiplicative with a(2^e) = 2^(e-2) for 2 <= e <= 5, a(2^e) = 0 for e = 1 or e >= 6; a(p^e) = gcd(p-1, 8)-1 if p > 2 and e = 1, a(p^e) = 0 if p > 2 and e >= 2.
%e Let w = exp(2*Pi*i/8) = sqrt(2)/2 + i*sqrt(2)/2. For n = 17, the 7 octic primitive Dirichlet characters modulo n are:
%e Chi_1 = [0, 1, -i, w, -1, -w, -w^3, w^3, i, i, w^3, -w^3, -w, -1, w, -i, 1];
%e Chi_2 = [0, 1, -1, i, 1, i, -i, -i, -1, -1, -i, -i, i, 1, i, -1, 1];
%e Chi_3 = [0, 1, i, w^3, -1, -w^3, -w, w, -i, -i, w, -w, -w^3, -1, w^3, i, 1];
%e Chi_4 = [0, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1];
%e Chi_5 = [0, 1, -i, -w, -1, w, w^3, -w^3, i, i, -w^3, w^3, w, -1, -w, -i, 1];
%e Chi_6 = [0, 1, -1, -i, 1, -i, i, i, -1, -1, i, i, -i, 1, -i, -1, 1];
%e Chi_7 = [0, 1, i, -w^3, -1, w^3, w, -w, -i, -i, -w, w, w^3, -1, -w^3, i, 1],
%e so a(17) = 7.
%t f[2, e_] := If[2 <= e <= 5, 2^(e-2), 0]; f[p_, e_] := If[e == 1, GCD[p-1, 8] - 1, 0]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* _Amiram Eldar_, Sep 16 2020 *)
%o (PARI) a(n)={
%o my(r=1, f=factor(n));
%o for(j=1, #f[, 1], my(p=f[j, 1], e=f[j, 2]);
%o if(p==2, if(e>=2&&e<=5, r*=2^(e-2), r=0; return(r)));
%o if(p>2, if(e==1, r*=gcd(p-1,8)-1, r=0; return(r)));
%o );
%o return(r);
%o }
%Y Number of k-th power primitive Dirichlet characters modulo n: A114643 (k=2), A160498 (k=3), A160499 (k=4), A307380 (k=5), A307381 (k=6), A307382 (k=7), this sequence (k=8).
%Y Cf. A247257 (number of solutions to x^8 == 1 (mod n)).
%K nonn,mult
%O 1,5
%A _Jianing Song_, Nov 10 2019