I am trying to code a modular equation solver, say given an equation,
$x^2=180345$ and the modulo is 8, then we can solve it like this-->
$x^2 = 180345 \bmod 8 = 1 \bmod 8$
Now, x can have only the following set of values mod 8:
{0, 1, 2, 3, 4, 5, 6, 7}
You can verify that only x = 1, 3, 5, 7 satisfy x^2 = 1 mod 8 and the other values do not.
A code for this will be as simple as-->
for i in range(1,8):
if( (i**2) % 8 == 1):
print(i)
But I am facing problem when it comes to large values.
for example, say this is the case now
$x^{2023}=60272843869801735644577066673$ and modulo is $19806040628566084345385967582$
With the same code that I mentioned it will take a lifetime to solve this equation, but when I use this online modular equation solver it is performing this operation within seconds. Can someone tell me what is the algorithm that they are using?