When finding whether there exists a solution for $x^2 \equiv a \pmod n $, one way is to calculate it with the Jacobi symbol. However, Jacobi symbol requires that $(a,n) = 1$. So I wonder when $(a,n) \neq 1$, will there also be a similar method to determine whether the solution exists or not.
Here's what I've tried:
Write n as $p_1^{k_1}p_2^{k_2}\ldots p_n^{k_n}$ and then $a$ must have a common factor. Assuming $a$ only has a common factor of $p_s^m$ while $p_s^{m+1}$ is not its factor. Let $d = {a \over p_s^m}$. Then we can use the Chinese remainder theorem to separate the part $x^2 \equiv p_s^m d \pmod {p_s^{k_s}}$ out, and the rest can be dealt with the Jacobi symbol. If there exist more common factors, then separate each of them out in the same manner.
So the problem reduces to $x^2 \equiv p_s^m d \pmod {p_s^{k_s}}$. And I'm close to being stuck. One way I thought about is to reduce $p_s^{k_s}$ to a lower power such as $p_s$ itself. As long as we can find a non-zero solution, we can use Hensel's lifting to find a solution that satisfies the original equation. Also if m is somehow even, we can reduce the problem to find whether there exists a solution such as $y^2 \equiv d \pmod {p_s^{k_s}}$. However, we can not assume it's even, so I'm also stuck.
I have spent a long time searching online for a solution but have not found anything appertaining to this question. I wonder why the Jacobi symbol is limited to relatively prime numbers. Is it too trivial to explain the case when they are not? So if they are not relatively prime, what techniques can we use to check whether a solution exists?
Thanks in advance.