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.
Claim - $R$ should be an `integral domain' for $f$ to have at most $n$ roots.
Proof - Let's consider the simplest equation $x^2-m=0$ where $m$ is a non-zero element in $R$. Suppose it has more than 2 roots i.e. $$x^2-m=(x-a)(x-b)=(x-c)(x-d), \enspace a,b,c,d \in R.$$ Let $c \neq a,b. $ Then $(c-a)(c-b)=0.(c-d)=0$ which implies $R$ is not an integral domain.