1

Given $p$ is prime and $y$ is a constant. What's the fastest possible way to find $x$ where $x^2\equiv y\bmod p$?

Example: $x^2\equiv97\bmod101$ would give us $x=81$ as one of the solutions. What's the fastest way to compute any one of the solutions of $x$?

Constraints:

  1. $0\le p\le10^9$
  2. $0\le y\le p$
  3. $0\le x<p$
Parcly Taxel
  • 103,344

1 Answers1

2

The standard approach to compute square roots modulo primes is the Tonelli–Shanks algorithm.

Parcly Taxel
  • 103,344