I've been looking at how zero divisors of 2x2 matrices behave with modular arithmetic, and I've come upon an interesting pattern that I am trying to better understand. Essentially, I'm looking for a way to count the number of zero divisors in modulus $n$ in the set of matrices over $S = \{0, 1, 2, ... n-1\}$. So here is my question, which involves a specific case of when the determinant can be divisible by $n$ :
Say $S = \{0, 1, 2, ... n-1\}$ and $a, b, c, d \in S$, is there a method to count how many times that $n \vert (ab-cd)$?
Or in other words, how many times will $(ab-cd) \% n = 0$?