# Solutions to $p+1=2n^2$ and $p^2+1=2m^2$ in Natural numbers.

$$p+1=2n^2$$$$p^2+1=2m^2$$ Find positive integers $m,n$ and prime $p$ satisfying the above two equations.

What would people commonly do?

Subtracting both the equations.

You get:

$$p(p-1)=2(m-n)(m+n)$$

If you notice carefully, the above equation has infinitely many solutions, and this doesn't work because the generality of the equation is lost when you subtract both of them.

I noticed that $p \equiv -1 \pmod 8$. $p=7$ works fine. I don't see any other solution, but not able to contradict of existence.

-
If you eliminate $p$ from the two equations, you get $m^2$ equal to a quartic in $n$. Such are known to have only finitely many integer solutions, but finding them all can be tricky. What's the source? – Gerry Myerson Jul 13 '13 at 9:11
If there are only finitely many solutions, then there are only finitely many solutions where $p$ is prime. – Gerry Myerson Jul 13 '13 at 9:13
@Inceptio What makes you think there will be an easier way of finding the prime solutions than finding all the solutions and picking out the ones which are prime? – Mark Bennet Jul 13 '13 at 9:14
Why shouldn't $p$ be $1$ mod $8$? – Chris Eagle Jul 13 '13 at 9:20
Note that the integer solutions to $r^2\pm 1=2s^2$ are the successive convergents to the continued fraction for $\sqrt 2$ - which is a useful fact to know for contests. These are formed by setting $a_0=1, b_0=1; a_r=a_{r-1}+2b_{r-1}, b_r=a_{r-1}+b_{r-1}$ giving the pairs $(1,1), (3,2), (7,5), (17,12), (41,29) \dots$ - alternate ones give the sign you need. – Mark Bennet Jul 13 '13 at 9:20

I think the $\mathit{commonly\ done}$ method works well and gives the single solution $(m,n,p)=(5,2,7)$. Maybe I am missing something, but I'm still giving the argument I have come up with. Kindly point out if there is any mistake.

First, note that $$p(p-1)=2(m-n)(m+n)\Rightarrow\ (m-n)|(p-1)/2$$ since $p$ is an odd prime here, $m,n$ positive. Then it implies that $p|(m+n)$. Now if $p\ne m+n$, then $(m+n)|(p-1)/2$ which consequently makes $p|(m-n)$ which is a contradiction. So $$\begin{split} m+n=& p \\ m-n=&(p-1)/2\\ \end{split}$$ This gives $$n=\frac{p+1}{4}$$ and this from the first equation given in the question leads to $p=7$. Then it follows from the above equations that $m=5,n=2$.

Edit: The solution I have given here is only one solution, and hence what I am claiming to be as single solution is wrong. There can be other solutions as pointed out by user70520. I will try to find those solutions too.

-
Why does that impplies that $p|(m+n)$? I mean, what if $p$ partially divides $m+n$ and $m-n$, while $p-1$ divides $2$ and the other part of $m+n$ and m-n? I can't get your argument, and I would appreciate very much an explanation. – chubakueno Jul 19 '13 at 2:55
@chubakueno What do you mean by $p\ partially$ divides? – Samrat Mukhopadhyay Jul 19 '13 at 9:11
Anyway, my argument is that since $p$ is a prime, it has to divide either $m+n$ or $m-n$. If say it divides $m^2-n^2$ but none of $m+n$ or $m-n$, then $p\nmid (m+n)$ but gcd$(m+n,p)\ne 1$ which is a contradiction to the fact that $p$ is a prime. – Samrat Mukhopadhyay Jul 19 '13 at 9:17
Oh, now i get it. And the fact that $p>p-1$ excludes $m-n$ from the possibilities. Thanks. – chubakueno Jul 19 '13 at 14:31
Exactly @chubakueno. – Samrat Mukhopadhyay Jul 19 '13 at 14:37

Yes, $p=7$ is the only solution. Given a prime $p$ as above, you obtain a Pythagorean triple, setting $a=2nm$, $b=n^2-m^2$ and $c=n^2+m^2$, which gives $$(p^3+p^2+p+1)+ \left( \frac{p^2-p}{2}\right)^2=\left( \frac{p^2+p+2}{2}\right)^2.$$ By the way, for $p=7$ we obtain $20^2+21^2=29^2$.
The condition, that $p^3+p^2+p+1$ is a square implies that $p=1$ or $p=7$ (not only for primes, but for all positive integers). In fact, the solution is given in Ribenboim's book on Catalan's conjecture, where all equations $y^2=1+n+n^2+\cdots +n^k$ are studied. For $k=3$, only $1$ and $7$ are possible.

-
By "similar argument" for $p^3+p^2+p+1=x^2$, do you mean to bound the LHS between two squares? But $3$ is odd. – user70520 Sep 2 '13 at 18:43
How do we show the only solution is $p=7$? Thank you. – user70520 Sep 2 '13 at 21:18
The proof can be found here: books.google.at/books/about/…. – Dietrich Burde Sep 3 '13 at 8:03
How does this have to do with Catalan's conjecture? – user70520 Sep 7 '13 at 2:59

Just some comments which format better in an answer that a comment. They may help give some insight into the nature of a solution.

Using the convergents to $\sqrt 2$ it is quick to check that there are no other small solutions ($p\lt 10^{14}$)

If we ignore the prime condition for a moment we have $p=2n^2-1$ so that $$(2n^2-1)^2+1=2m^2$$

Which reduces to $$4n^4-4n^2=2m^2-2$$ or$$2n^2(n+1)(n-1)=(m+1)(m-1)$$

The left hand side is divisible by $8$. Noting that the highest common factor of $m+1$ and $m-1$ must divide their difference $2$, either $m+1$ or $m-1$ must be divisible by $4$. If $n$ is odd, this is replaced by $8$.

The left hand side is also divisible by 3, so either $m+1$ or $m-1$ is divsible by $6$ (both have to be even).

This form of the equation suggests there may be other constraints which are demanding to meet.

Note also that $m$ must be odd, so the right-hand side is eight times a triangle number, while the left-hand side is $8$ times the product of two successive triangle numbers - namely, with $m=2r+1$ we can cancel a factor $8$ to obtain $$\frac{n(n+1)}2\cdot\frac {n(n-1)}2=\frac{r(r+1)}2$$

-

Here's Mahoney's proof [p.338].

Let $(u_0,w_0)$ be a solution of $$2U^2-W^2=p. \tag{1}$$ Then $$(u_1,w_1) = (2u_0^2 \pm 2u_0w_0 + w_0^2,2u_0^2\pm 4u_0w_0 + w_0^2)$$ is a solution of $2U^2-W^2=p^2.\tag{2}$ If, moreover, $(u_0,w_0)$ is the least solution of (1), then $(u_1,w_1)$ with the minus sign is the least solution of (2). Therefore suppose $2u_0^2-1=p$. Then $$(u_1,w_1)=(2u_0^2-2u_0+1,2u_0^2-4u_0+1)\tag{\star}$$ is a solution of (2). But clearly $(u_0,1)$ is the least solution of (1); hence $(\star)$ gives the least solution of (2). By assumption, we have $w_1 = 1 = 2u_0^2-4u_0+1$, so $u_0=2$, and $(2,1)$ is the only solution of (1). Hence $p=7$.

-