Solution (source code)

= Solution

A nonzero <polynomial> of degree $n$ over a <field> has \b[at most $n$ distinct roots in that <field>]. For a proof, the <factor theorem> gives $(t-a)\mid f(t)$ whenever $f(a)=0$. Distinct linear factors are coprime in $K[t]$, a <unique factorization domain>, so for distinct roots $a_1,\ldots,a_k$ their product divides $f$. Its degree is $k$, giving $k\leq n$. One may equivalently remove one linear factor at a time and argue by induction.

If the <field> has at least $n$ elements, this bound is attained by a product of $n$ distinct linear factors. For a fixed finite <field> with fewer than $n$ elements, the largest possible number of distinct roots is $\min(n,|K|)$ instead; multiplicities do not create more distinct roots. The zero <polynomial> is excluded since it has no finite degree.