Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to prove following statement :


Odd prime $p$ is expressible as : $p=\sqrt{x^2+7\cdot y^2}$ , $x,y > 0$

if and only if : $p\equiv 1 \pmod {7}$ or $p\equiv 2 \pmod {7}$ or $p\equiv 4 \pmod {7}$ .

Note that $7$ is an Idoneal Number .

share|cite|improve this question
up vote 4 down vote accepted

First, check that $p=7$ is not expressible as such a square root.

Next, suppose $p$ is an odd prime other than $7$. $p^2 = x^2 + 7y^2$ means that $p² = (x + y \sqrt{-7})(x - y \sqrt{-7})$. So you are looking for non-trivial factorisations of $p^2$ in $\mathbb{Z}[\sqrt{-7}]$.

Note that $\mathbb{Q}(\sqrt{-7})$ has class number 1, so its ring of integers, $\mathbb{Z}[\frac{1+\sqrt{-7}}2]$, is a unique factorisation domain.

If $-7$ is a square mod $p$ then $p$ factors into $q \bar{q}$, and you have $p^2 = (q^2)(\bar q^2)$. Now, if $q = \frac{a+b\sqrt{-7}}2$ with $a$ and $b$ odd, then $a^2,b^2 \equiv 1 \mod 8$, so $q\bar{q} = \frac{a^2+7b^2}4 \equiv 0 \mod 2$. Since $p$ is odd, this can't be the case, thus you get $p^2 = (q)^2(\bar q)^2$ with $q^2, \bar{q}^2 \in \mathbb{Z}[\sqrt{-7}]$

Furthermore, write $q^2 = x+y\sqrt{-7}$, so $p^2 = x^2+7y^2$. If $x=0$ then $(p/y)^2 = 7$, which is impossible because $7$ is not a square in $\mathbb{Q}$. If $y=0$ then $q^2 = x = p$ which is impossible because $p$ is not a square in $\mathbb{Q}[\sqrt{-7}]$. Thus, changing the signs of $x,y$ if needed, $p = \sqrt{x^2+7y^2}$ with $x,y>0$.

If $-7$ is not a square mod $p$, then $p$ is irreducible, so $p^2 = p*p$ is the only possible factorization (up to sign), so $p = \sqrt{x^2+7y^2}$ implies $x= \pm p, y=0$.

The quadratic reciprocity law does the rest : $-7$ is a square mod $p$ if and only if $p$ is a square mod $7$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.