# Find all the prime integer solutions to $q^2(p-1)=(p+1)(q+1)$

Let $p,q$ be prime numbers. Find all the integer solutions to: $$q^2(p-1) = (p+1)(q+1)$$

I am almost sure that $q=2$,$p=7$ is the only solution. Thus I assumed that $p$ and $q$ were both odd to reach a contradiction, but so far I haven't made any progress that way.

• I notice that $q$ cannot be very big, for example. What have you tried? – hardmath Jun 25 '14 at 16:23
• I am almost sure that $q=2, p=7$ is the only solution. Thus I assumed that $p,q$ were both odd to reach a contradiction, but so far I haven't done any progress on that way. – Sancho Jun 25 '14 at 16:25

You're on the right track assuming that $p,q$ are odd.

Here's the step you may be missing: if $p>2$ is odd, then $(p-1, p+1) = 1$. But $(p+1)$ must divide both sides of the equation. So $(p+1)\mid q^2$. Hence $q$ is even.

• WOAH thanks.... – Sancho Jun 25 '14 at 16:52
• How did I miss that? :P – Sancho Jun 25 '14 at 16:53
• Happens to all of us :) – Mathmo123 Jun 25 '14 at 16:54
• $(p−1,p+1)=2$ if $p$ is odd. – lhf Jun 25 '14 at 17:16
• Right you are... give me a sec – Mathmo123 Jun 25 '14 at 17:18

We show how to solve a different problem, finding the integer solutions of $q^2(p-1)=(p+1)(q+1)$. There are not many.

We can have $p=1$, which forces $q=-1$. If $p\ne -1$, then $\left|\frac{p+1}{p-1}\right|\le 3$.

Note that if $|q|\ge 4$ then $\left|\frac{q^2}{q+1}\right|\gt 3$.

So the only candidates for $q$ lie in the interval $-3\le q\le 3$. Try them all. In each case we get a linear equation for $p$.

If we are really only interested in primes, the only numbers that need to be tried are $q=2$ and $q=3$.

• Please explain a little bit more ... How you got if $p \not = -1$, then $\left|\frac{p+1}{p-1} \right| \leq 3$...Didn't get this – Rezwan Arefin Feb 1 '17 at 15:20

If we assume $p,q$ are positive primes, we can proceed by first showing $q=2$ and then deduce $p=7$.

Note $q-1 = (q^2-1)/(q+1) \lt (p+1)/(p-1)$. For any positive prime $p$, the right hand side is at most 3, so $q$ must be less than 4. Thus $q$ is either 2 or 3.

If $q=3$ we can refine this estimate a little. Since $q^2$ divides $p+1$, because $q$ and $q+1$ are coprime, for $q=3$ would mean $p+1$ is a multiple of 9. This first happens for prime $p=17$. In any case $(p+1)/(p-1)$ would be less than 2, so $q \lt 3$. This contradiction implies $q=2$.

Plugging that value for $q$ into the original equation quickly gives $p=7$.

For completeness sake you should examine whether one or both $p,q$ can be negative primes.

• Negative numbers are typically considered not prime. – JimmyK4542 Jun 25 '14 at 16:57

$q^2(p−1)=(p+1)(q+1)$

This can be written as:

$\frac{q^2}{q+1} = \frac{p+1}{p-1} = 1 + \frac{2}{p-1}$

In other words, subtracting 1 from both sides,

$\frac{q^2 - q - 1}{q+1} = \frac{2}{p-1}$

Two cases here:

1) p = 2. So $q^2 - q - 1 = q+1$. Gives: $q^2 - 2q - 2 = 0$. Easy to see this has no integer solutions (just solve the quadratic equation).

2) p is an odd prime. Let p = 2k + 1.

Then $q + 1 = k(q^2 - q - 1)$. So $(q+1)(k+1) = kq^2$.

Now, q and q+1 are co-prime. So are k+1 and k. Unless k or q is 1, this can only mean:

$q+1 = k$ and $k+1 = q^2$ So $q+2 = q^2$ Solving the quadratic, q = 2 or q = -1. 'q is prime' makes us reject q = -1 case. So q = 2. So p = 2k+1 = 2(q+1) + 1 = 7.

Now, suppose k = 1. Then we get: $2(q+1) = q^2$. This again gives $q^2 - 2q - 2 = 0$ which has no integer solutions.

q = 1 gives: $2(k+1) = k$. This gives k = -1/2, which is not an integer.

So p = 7, q = 2 is the only solution to this.