%I #27 Jul 08 2019 10:17:58
%S 2,1,1,1,1,2,1,1,1,2,1,2,1,2,2,1,1,2,1,2,2,2,1,2,1,2,1,2,1,2,1,1,2,2,
%T 2,2,1,2,2,2,1,2,1,2,2,2,1,2,1,2,2,2,1,2,2,2,2,2,1,2,1,2,2,1,2,2,1,2,
%U 2,2,1,2,1,2,2,2,2,2,1,2,1,2,1,2,2,2
%N The number of distinct nonzero coefficients in the n-th cyclotomic polynomial.
%C The sum of the coefficients in the n-th cyclotomic polynomial is given by A020500.
%C The first occurrence of 4 in this sequence is a(330).
%H Colin Barker, <a href="/A230799/b230799.txt">Table of n, a(n) for n = 1..1000</a>
%e a(12)=2 because the distinct nonzero coefficients of the 12th cyclotomic polynomial, x^4 - x^2 + 1, are 1 and -1.
%p A230799 := n -> nops({coeffs(numtheory[cyclotomic](n,z),z)}):
%p seq(A230799(n), n=1..86); # _Peter Luschny_, Oct 30 2013
%t a[n_] := List @@ Cyclotomic[n, x] /. x -> 1 // Union // Length;
%t Array[a, 100] (* _Jean-François Alcover_, Jul 08 2019 *)
%o (PARI) a(n) = v=vecsort(Vec(polcyclo(n)), , 8); if(has_zero(v), #v-1, #v)
%o has_zero(v) = for(i=1, #v, if(v[i]==0, return(1))); 0
%o (PARI) {a(n) = if( n<1, 0, #setminus( Set( Vec( polcyclo(n))), [0]))};
%o /* _Michael Somos_, Mar 27 2014 */
%Y Cf. A020500, A230798.
%K nonn
%O 1,1
%A _Colin Barker_, Oct 30 2013
|