How many zero divisors are there in $\mathbb Z_{pq}$ and $\mathbb Z_{p^2}$ when $p$ and $q$ are primes? First of all, I'm still trying to prove that $a \in \mathbb{Z}_n$ is a zero divisor if and only if $\gcd(a,n)>1$, so if anyone wants to help me finish the details on that that'd be awesome.
But assuming I have proven that! I now need to figure out how many zero divisors there are in $\mathbb Z_{pq}$ and $\mathbb Z_{p^2}$. This seems like it should be a simple counting argument that I am making  more complicated than need be.
Thanks.
 A: Remember that a zero divisor is an $a$ such that exists $b$ nonzero, with $ab=0$. So, for example in the case of $\mathbb{Z}_{pq}$, that would be an $a$ such that there is a nonzero $b$ with $ab=kpq$, for some $k \in \mathbb{Z}$. Automatically $p|ab$, $q|ab$. Since $p$, $q$ are prime, you would have either $p|a$ or $p|b$, and $q|a$ or $q|b$. So, the number of zero divisors would be the sum of zero divisors $a$ multiples of $p$, plus the number of zero divisors $a$ multiples of $q$. That is $q+p-1$ (you are counting $0$ twice). What makes this two sets of possibilities having just one element in common is that the only common multiple is $pq=0$. 
For $\mathbb{Z}_{p^2}$, your equation becomes $ab=kp^2$. Then this would imply $p|a$ and $p|b$, or $p^2|a$ or $b$ (this two last possibilities would imply either $a=0$ or $b=0$, so you rule them out). Then $a$ could be any multiple of $p$. that is, $p$ zero divisors (because $p\cdot 0=p\cdot p$).
As of your first question: $a$ is a zero divisor in $\mathbb{Z}_n$ iff $ab=kn$ has a nonzero solution in $b$ for some $k\in \mathbb{Z}$. If $(a,n)=1$, then $n|b$, so $b=0$ and $a$ is not a zero divisor (take now the counter-reciprocal). For the other implication: if $(a,n)=r>1$, then just take $b=\frac{n}{r}$, $ab=n=0$ and $b\neq 0$, so that $a$ is a zero divisor.
