I need to determine all primes p for which -5 is a quadratic residue modulo p. The original question is

Find the odd primes which divide integers of the form $n^2+5$ ?

My try:

what I obtain is ... $$n^2 \equiv (-5) \mod p$$ I know how to solve $n^2 \equiv 5 \mod p$ what is the difference if it is replaced by -5 . Does it mean... every prime of the form $$p=\pm 1 , \pm3 \mod 10 ??$$

  • 3
    $\begingroup$ Do you know about the Legendre symbol and specifically its multiplicative properties? $\endgroup$
    – Mastrem
    May 31, 2019 at 8:13
  • 3
    $\begingroup$ That would be every odd prime except $5$, which is not right. First note that $5$ must be included (eg the square $0^2=0\equiv -5 \bmod 5$ - it is easy to miss special cases. It would be helpful if you could show some workings - at the moment it is hard to see what you may have done - but the quadratic character of $-1$ modulo $p$ depends on $p\bmod 4$ $\endgroup$ May 31, 2019 at 8:13

2 Answers 2


We have the Legendre symbol $$\left(\frac{-5}p\right)=\left(\frac5p\right)\left(\frac{-1}p\right)=+1$$

There are two main cases:

  • If both Legendre symbols are $+1$, then (as already shown) either $p=5$ (the exceptional case) or $p\equiv\pm1\bmod5$. $\left(\frac{-1}p\right)=+1$ precisely when $p\equiv1\bmod4$. Combining these two congruences yields $p\equiv1,9\bmod20$.
  • If both Legendre symbols are $-1$, solving each symbol yields $p\equiv\pm2\bmod5$ and $p\equiv3\bmod4$, or $p\equiv3,7\bmod20$.

Therefore, the odd primes that are factors of $n^2+5$ are $5$ and those congruent to $1,3,7,9\bmod20$.


The possible prime factors upto $5$ are $2,3,5$ which can be found out by inspection.

For primes $p>5$ , we have to distinguish between two cases :

$(1)$ $p=4k+1$. In this case, $-1$ is a quadratic residue and hence also $5$. So, the possible forms are $20k+1$ and $20k+9$

$(2)$ $p=4k+3$. In this case, $-1$ is not a quadratic residue, so neither is $5$. So, the possible forms are $20k+3$ and $20k+7$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .