What is the general method for solving congruences of the form $x^2\equiv a \bmod p$, where p is prime?

78 Views Asked by At

For example $x^2 \equiv 13 \bmod 29$. The only solution that comes to mind is to just calculate the squares of all of the numbers from 0 to 28, but that's tedious. Is there a better method?

EDIT: the question that this is marked as a duplicate to doesn't contain an answer as to how to solve such congruences, only for determining whether there exists a solution. So while a similar question has been asked, it hasn't been properly answered and IMO it's not duplicate then.

1

There are 1 best solutions below

0
On BEST ANSWER

One technique I've found for this is to try to complete the difference of squares. For example, consider $x^2\equiv24\bmod{125}$. We can notice that $24\equiv1024 \bmod 125$, so we have $x^2-1024\equiv(x-32)(x+32)\equiv0\bmod125$ and from that it easily follows that $x\equiv32\bmod 125$ or $x\equiv-32\equiv93\bmod 125$. We can eliminate the possibility of $(x-32)(x+32)$ being a number that is divisible by 125 because the two numbers differ by 64, and they would both have to be divisible by 5 for their product to be divisible by 125.