How to get all solutions of $x^2 \equiv$ $a$ mod $p$?

4.7k Views Asked by At

So I'm trying to find all solutions of $x^2 \equiv$ $a$ mod $p$ and for some reason the formulas that are suggested everywhere online (for example, here) say that, if p is an odd prime and you have a congruence like this:

enter image description here

Then you can find the solutions with this (if there are any):

enter image description here

That's what I was taught as well, but when entering examples into Wolfram Alpha, I've noticed that there are actually more solutions - these formulas just give you one of them! For example:

If I need to find the solutions of: x^2 ≡ 8 (mod 23) and I use the above formulas, I get the solution: x = +- 13, but Wolfram Alpha says that +-10 also works (and it does). So why is that? Why do these formulas only give you 1/2 of the answer and why can't I find a way to find the whole answer (excluding the way where you draw the table with x^2 mod p for x from 0 to p and)?

I realize that I'm probably doing something wrong and I'm not very good at this in the first place, but I've spent hours searching for an answer and couldn't really find anything (that I could understand, at least).

1

There are 1 best solutions below

3
On BEST ANSWER

There are never more than two solutions if $p$ is prime. Note for example that $13\equiv -10\pmod{23}$.