It is known that a polynomial in an integral domain has at most as many roots as its degree. So conversely a polynomial with more roots that its degree has to be in a ring with zero divisors. For example in $\mathbb{Z}_8$ the equation $x^2 = 1$ has the solutions $1$, $3$, $5$ and $7$, and indeed $\mathbb{Z}_8$ has the zero divisors $2$, $4$ and $6$. Is there a way to construct these zero divisors from $1$, $3$, $5$ and $7$? More generally, given the roots $\{x_1, \dots, x_n\}$ of a polynomial $p \in R[X]$, how do I construct zero divisors of $R$ when deg $p < n$?
The most immediate idea is to write $p$ as $(X - x_1) \cdot \dots \cdot (X - x_{\textrm{deg } p})$ and then plugging in $x_n$ for $X$. Since $x_n$ is a root, this product equals $0$ and therefore consists of zero divisors. But writing $p$ as this product simply doesn't work in non-integral domains. If we take our example from before, then $(X - 1) \cdot (X - 3) = X^2 - 4X + 3$ and not $X^2 - 1$. But it feels like this idea should work, so how do I fix it?