2Shanks’s algorithm appeared in his paper, “Five number-theoretic algorithms”, in Proceedings of the Second Manitoba Conference on Numerical Mathematics, Congressus Numerantium, No. VII, 1973, 51–70. Our treatment is taken from the paper by Jan-Christoph Schlage-Puchta”, “On Shank’s Algorithm for Modular Square Roots”, Applied Mathematics E-Notes, 5 (2005), 84–88.