An algorithm which finds the least nonnegative value of for given and prime .
Shanks' Algorithm
Explore with Wolfram|Alpha
Cite this as:
Weisstein, Eric W. "Shanks' Algorithm." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/ShanksAlgorithm.html