TITLE: Condition on monic second-order polynomials so that a commutative ring is an integral domain
QUESTION [6 upvotes]: I am trying to prove this result: 

Let $A$ be a commutative ring different from $\{0\}$, $\mathbb{Z}/4\mathbb{Z}$ and $\mathbb{Z}/2\mathbb{Z}[X]/(X^2)$. Prove that if any monic polynomial of degree $2$ of $A[X]$ has at most two roots in $A$, then $A$ is an integral domain.

I have tried to suppose that $A$ is not an integral domain, so that $\exists a,b\in A$ with $a,b\ne 0$ and $ab=0$. If $a\ne b$, the polynomial $X(X-a+b)$ has three different roots: $0,a-b,$ and $a$, which is absurd.
However, if $a=b$ (so that $a^2=0$), I can't find a way to come to an absurdity. The polynomial $X^2$ has two different roots: $0$ and $a$, as well as any $xa$ for $x\in A$. An absurdity will occur if there exists $x\in A$ such that $xa\notin \{0,a\}$, and I can't see why just putting apart the three aforementioned rings ensures that it is the case.

REPLY [3 votes]: As the OP mentioned the problem reduces easily to the following situation: 

If $A$ is not an integral domain and $a\in A-\{0\}$ is a zerodivisor, then $a^2=0$ and $ba\neq 0$ for any $b\in A-\{0,a\}$. 

What conclusion can we draw now about the ring $A$? Well, we get that $A$ is exactly one of the excluded rings: since $(ba)a=0$ and $ba\neq 0$ we must have $ba=a$, so $b\in A-\{0,a\}$ implies $ba=a$, equivalently $(b-1)a=0$. This gives us two possibilities: $b=1$ or $b=a+1$. We thus get $A=\{0,1,a,a+1\}$ and $a^2=0$. Now we can have $1+1=0$, $1+1=1$, or $1+1=a$. In the first case $A\simeq\mathbb Z_2[X]/(X^2)$, in the second case $A=\{0\}$, while in the third case $A\simeq\mathbb Z_4$, a contradiction.