TITLE: Total number of roots of a polynomial of degree $n$ over a ring $R$
QUESTION [8 upvotes]: Let $R$ be a commutative ring with unity and $f$ be a polynomial of degree $n$ over $R$. Under what conditions on $R$, does $f$ has at most $n$ roots ?
I am asking because in $\mathbb{Z}/12\mathbb{Z}$, the polynomial $x^2-4$ has 4 roots $2,4,8,10$ since $X^2-4=(x-8)(x-4)=(x-10)(x-2)$.
The above example shows unique factorization is necessary. So I believe, $R$ should be a UFD as $R[x]$ will also be a UFD then.

REPLY [5 votes]: Let $R$ be a commutative ring where each degree $n$ polynomial has at most $n$ roots ($n>0$).
Suppose $R$ is not a domain; then there are $a,b\in R$, both nonzero, with $ab=0$. Consider now
$$
f(x)=(x-a)(x-b)=x^2-(a+b)x+ab=x^2-(a+b)x
$$
This degree two polynomial has at least three roots, provided $a\ne b$. Contradiction.
This leaves open the case where in the ring it holds that $ab=0$ if and only if $a=b$, when $a\ne0$ is a zero divisor. But then the polynomial $x^2$ has all zero divisors as roots. If there's more than one nonzero zero divisor we are done. Thus we reduce to the case the ring has a single nonzero zero divisor $a$. Since $2a$ is clearly a zero divisor and $2a\ne a$, we conclude $2a=0$. Therefore $2=0$ in $R$ or $a=2$ (identifying $2$ with $2\cdot 1$).
In the former case the characteristic of $R$ is $2$, in the latter case the characteristic is $4$, because $a^2=0$ by assumption.
Suppose the characteristic of $R$ is $4$. Then $2x-2$ has two distinct roots, namely $1$ and $-1$: contradiction.
Thus we remain with the case when the characteristic is $2$ and the ring has exactly one nilpotent element $a\ne0$ with $a^2=0$ and no other nonzero zero divisor. The nilradical of $R$ is then $\{0,a\}$. Hence, for every $r\in R$, we have $ar=0$ or $ar=a$. By assumption, $ar=0$ can only hold for $r=a$ or $r=0$. Take $r\in R$, $r\ne 0$ and $r\ne a$. Then $ar=a$, so $a(r-1)=0$. Therefore $r-1=0$ or $r-1=a$.
Then the ring is $R=\{0,1,a,1+a\}\cong\mathbb{F}_2[x]/(x^2)$. This should be the only counterexample to $R$ not being a domain.
Of course, for a domain the statement holds.