solving quadratic modular equations by factoring I am trying to solve the equation
$(x-a)(x-b)\equiv 0 \pmod m$
And I am wondering if checking two equations $x-a\equiv k \pmod m$ and $x-b\equiv \frac{m}{k} \pmod m$ for all $k\mid m,$ would find all solutions $x$ under mod $m.$ (combined with the initial case where m divides $x-a$ or $m$ divides $x-b$)
 A: If $m$ is prime that all solutions of the quadratic equation will be found that way. But consider
$$
(x- 2)(x-1)\equiv0\pmod6.
$$
This has four distinct solutions: $0,1,2,4,5.$ When $x\equiv4$ then $(x-2)(x-1)\equiv 2\cdot3\equiv0$ and when $x\equiv5$ then $(x-2)(x-1) \equiv 12\equiv0.$
The reason this can happen with a composite number like $6$ is you can multiply two non-zero numbers and get $0,$ thus $2\cdot3\equiv 0.$
The usual quadratic formula works when the modulus is an odd prime number (as opposed to the one even prime number, $2$), except that dividing by $2a$ has to be construed as multiplying by the multiplicative inverse of $2a$ modulo the prime number in question, and instead of saying $b^2-4ac$ is positive, you have to say $b^2-4ac$ has a square root. Half of all non-zero (congruence classes of) numbers will have square roots.
A: I believe the answer is no, but the difference between the algorithm you proposed and what would work is a little more subtle than described in Michael Hardy's answer.
It seems that you have tried to account for non-zero zero divisors (in other words  numbers that multiply to zero) by including the possibility that $x-a\equiv k\pmod{m}$ and $x-b\equiv m/k\pmod{m}$ for some factor $k$ of $m$. This does produce solutions like $x\equiv 4$. However, this does not cover all cases, because zero divisors in $\mathbb{Z}/m\mathbb{Z}$ aren't all factors of $m$, they can also be factors of a multiple of $m$. In fact, all numbers that are not coprime to $m$ are zero divisors. For example as Michael Hardy points out, $4$ is not a factor of $6$, but $4\times 3\equiv 12\equiv 0\pmod{6}$, and note that $\gcd(4,6) = 2$.
Therefore to fix your algorithm, you should consider all zero divisor pairs $p$ and $q$, i.e. $pq\equiv 0\pmod{6}$, and check $x-a\equiv p\pmod{m}$ and $x-b\equiv q\pmod{m}$.
