# Finding all prime numbers $x$ for which $24x+1$ is a perfect square

Clearly, a prime fits the criteria if the result of $\sqrt{24x+1}$ is an integer. By trial and error, I have found that seemingly the only primes to fit this criteria are 2, 5 and 7. How would I go about proving that they are the only ones (or, alternatively, that $x$ must be below a certain value and the only primes below this value that fit the criteria are 2, 5 and 7)?

I've gotten as far as stating that for some integer $a$:

$24x + 1 = a^2$

Then, I rearranged this to give:

$24x = a^2 - 1\\ 24x = (a+1)(a-1)$

I'm not quite sure where to go from here in order to complete the proof that $x$ cannot be above a certain value. Any help would be much appreciated! I'd prefer hints on where to go next rather than full solutions since I'd much rather reach the full solution myself.

• $x$ is a prime and divides $(a+1)(a-1)$ by your last equality. Therefore ... HTH, AB, – martini Mar 7 '12 at 14:38
• @martin HTH, AB? – Graphth Mar 7 '12 at 14:39
• @Graphth: For HTH see en.wikipedia.org/wiki/HTH, AB is short for "Allzeit bereit" which is a German variant of "Be prepared" (en.wikipedia.org/wiki/Scout_Motto), AB, martini. – martini Mar 7 '12 at 14:44
• You are very much on the right track. You might want to suppose that $x >7$ and try to derive a contradiction. You might also use the fact that $x$ can't divide both $a+1$ and $a-1$ if $x >7.$ – Geoff Robinson Mar 7 '12 at 14:45
• For an approach with lots of writing and little thinking, try just writing out all the possible factorizations of $24x$ into two integers (remember $x$ is prime, so there aren't many) and see what happens if you let one factor be $a+1$ and the other be $a-1$. – Chris Eagle Mar 7 '12 at 16:25

Your approach leads to a solution. As a continuing reminder that $x$ is supposed to be prime, let's call it $p$. We have $$24p=(a-1)(a+1).$$ Since $p$ divides the left-hand side, $p$ divides the right-hand side. It follows that (i) $p$ divides $a-1$ or (ii) $p$ divides $a+1$. (We are not excluding the possibility that $p$ divides both.)
Case (i): Suppose that $p$ divides $a-1$. Then $a-1=pk$ for some integer $k$. It follows that $a+1=pk+2$, and therefore $$24p=(pk)(pk+2).$$ By cancellation, we conclude that $$24=k(pk+2).$$ Now case (i) is in principle finished. We must have $pk+2 \le 24$, so $pk \le 22$. In particular, $p \le 19$, so it is a question of checking a small number of possibilities. The checking can be done efficiently, or not so efficiently.