For distinct odd primes $p, q$ we have $\sqrt{p^2 - 4q}$ is always irrational?

I am trying to show that $\sqrt{p^2 - 4q}$ is always irrational with $p, q$ as described above. Any hints?

$p^2$ leaves a remainder $1$ when divided by $8$ and $4q$ leaves a remainder $4$ when divided by $8$ as $q$ is odd, hence $p^2-4q$ leaves a remainder $5$ when divided by $8$, hence cannot be a perfect square as odd perfect squares leave a remainder $1$ when divided by $8$.

And $\sqrt n$ is an irrational if $n$ is not a perfect square, hence the fact $\sqrt{p^2-4q}$ is irrational is not only true for odd primes $p,q$ but also for odd numbers $p,q$.

• Brilliant...How do I think like this? May 22, 2017 at 8:41
• Checking modulo is a common practice for basic number theory problem May 22, 2017 at 8:44

First idea that came to mind: If $$n$$ is odd, $$n^2\equiv 1\pmod 8$$. However, if $$q$$ is odd, $$p^2-4q\equiv -3\pmod 8$$

Second way: If $$\alpha^2=p^2-4q$$, then $$\frac{-p+\alpha}2$$ and $$\frac{-p-\alpha}2$$ are the roots in $$\Bbb C$$ of the polynomial $$x^2+px+q$$, which are rational if and only if $$\alpha$$ is rational. However, by the rational root test and primality of $$q$$, the only possible such roots are $$x=\pm 1$$ or $$x=\pm q$$. In all these cases the quantity $$x^2+px+q$$ is the sum of three odd integers, thus odd and non-zero.

Roughly the same argument works, which is not a surprise, for $$p$$ and $$q$$ odd (not necessarily prime) integers.

$\sqrt {p^2-4q}\;\in \mathbb Q$ iff $p^2-4q=m^2$ with $m\in \mathbb Z^+\cup \{0\}.$

If $m\in \mathbb Z\cup \{0\}$ and $p^2-4q=m^2$ then $(p-m)(p+m)=4q.$ Now $p$ is odd so $m$ is odd. (If $m$ were even then $(p-m)$ and $(p+m)$ would both be odd, causing $4q$ to be odd.). So $(p-m)$ and $(p+m)$ are even.

So $\frac {p-m}{2}\cdot \frac {p+m}{2}=q\;$ with non-negative integers $\frac {p-m}{2}$ and $\frac {p+m}{2}.$

But $q$ is prime and $p>0$ and $m\geq 0 ,$ so this requires $1=\frac {p-m}{2}$ and $q=\frac {p+m}{2}.$

Adding, we have $1+q=\frac {p-m}{2}+\frac {p+m}{2}=p.$ But $1+q=p$ contradicts the hypothesis that $p$ and $q$ are both odd.

Note that $q$ is required to be prime but $p$ is only required to be an odd positive integer.