# Prove that $24n+5$ can't be a perfect square with $n \in \Bbb Z^+$

Prove that $24n+5$ can't be a perfect square with $n \in \Bbb Z^+$

My try

I tried to prove it by contradiction:

Assume that $24n+5=a^2$ with $a\in \Bbb Z^+$

Then $24n+5$ is odd, so $a$ is odd too

Then $$n=\frac {a^2-5}{24}$$

So $a^2-5|24$

I saw that if $a^2-5|24$, then $a$ must have a remainder of 5 when is divided by 24.

Example: Let $a^2-5=24$, then $a^2=29$ and $29/24=1$ with remainder of 5.

Let $a^2-5=48$, then $a^2=53$ and $53/24=2$ with remainder of 5.

So the problem reduces to finding a perfect square that divided by $24$ gives a remainder of $5$. I tried by brute force with all $a\ge 7$ (because $a$ is odd, so i tried $7,9,$... till $25$) and they all give remainder of $1$ or $9$. I know this doesn't suffices that there isn't a perfect square that divided by 24 gives remainder of $5$, but i don't know how to continue. I'm thinking about modular arithmetic and congruency, but i don't see the way.

Any hints?, or atleast is my way is correct?.

Thanks.

• if $24n+5$ is odd then $a^2$ is odd, then $a$ is odd. So let $a=2k+1$. Then $a^2 = 4k^2 + 4k + 1 = 24n+5$. This implies that $k^2+k=6n+1$ Notice that $6n+1$ is always odd while $k^2+k$ is always even. Contradiction. Apr 15, 2018 at 0:57
• @CogitoErgoCogitoSum thats all, thanks you. Apr 15, 2018 at 1:03

Assume for contradiction that $24n+5$ was a perfect square. Then for some $a\in\mathbb{Z}$, we have $24n+5=a^2$. Since $a$ is an integer then $a^2$ is an integer, thus $24n+5$ must be odd, meaning that $a^2$ is odd, therefore meaning that $a$ is also odd. So for some $k\in\mathbb{Z}$, $a=2k+1$ and thus $a^2 = 4k^2+4k+1$. And we have the equation $24n+5=4k^2+4k+1$. This implies that $6n+1=k^2+k$. But notice that $6n+1$ is always odd and $k^2+k$ is always even. A contradiction.

Modulo $8$, the squares are $0,1,4$. But $24n + 5 \equiv 5 \pmod{8}$, so cannot be a square.

Ultimately this is the same as the other solutions here, but slightly slicker to write down (except zwim's, which appeared after this one and is way nicer).

• We can also employ $\pmod3$ Apr 16, 2018 at 6:28

$\begin{array}{c|cc} a & a^2\pmod 3\\\hline 0 & 0\\ 1 & 1\\ 2 & 1\end{array}\quad$ but $\quad24n+5\equiv 2\pmod 3\quad$ so it cannot be a square.

$a$ is odd so $a=2k+1$ and thus $$a^2=4k(k+1)+1\equiv 1(\mod 8).$$

Suppose numbers of the form $24n+5$ are perfect squares. Then

$$a^2-5|24\ \Rightarrow\ a^2\equiv5\bmod 24,$$ which means that $5$ is a quadratic residue modulo $24$. But the set of quadratic residues modulo $24$ are $\{0,1,4,9,12,16\}$. Contradiction.

Thus, numbers of the form $24n+5$ are not perfect squares.

• The answer isnt wrong. But the problem with this answer is that you have to calculate all quadratic residues. For one, this requires computation, and for two, you have to prove youve found all of them. This seems like more work. Apr 18, 2018 at 16:39
• Yes, upon reflection, there are far more sleeker answers here. I will very much take this on board, all part of the learning experience! Apr 18, 2018 at 16:51