Suppose I have a number $k$ such that $k < p$ but $k^2 > p$
Now I need to find smallest possible value of n such that
$n^2 \bmod p\equiv k^2 \bmod p$
I found a pattern $k^2 \bmod p \equiv (p - k)^2 \bmod p$.
Is there any other method? Are there any set of numbers if not all for which we can find such a number easily.
$P$ is not specifically a prime. It is any arbitrary positive number.