# Diophantine equation, help needed

I am currently working on a problem with Diophantine equations

I need to prove (if it is true, which seems to be the case) the following :

Let $$x,y \in \mathbb{N}$$ be natural numbers, and $$n \in \mathbb{N}$$.

Let E be the following equation $$x^2-y^2=n \;(E)$$

then the couple $$(x,y)=(\frac{n+1}{2};\frac{n-1}{2})$$ is the unique solution iff $$n$$ is both an odd and prime number

What I managed to prove so far :

E has at least one solution iff $$n=pq$$ with $$p \& q$$ both odd or both even.

From there, I also proved that if $$n$$ is odd, then E has at least one solution.

Is it possible to prove what I need from this point ? Any help will be appreciated !

T.D

• What is the relevance of $n$ being prime? Surely there are solutions with $n$ an odd composite, eg $(\frac{15+1}{2})^2-(\frac{15-1}{2})^2=8^2-7^2=15$? – Adam Bailey Oct 28 '19 at 22:41
• @AdamBailey I have a program that uses odd prime numbers to do some deciphering. This could be of use to check the key provided by the user. – T.D. Oct 29 '19 at 7:41
• @AdamBailey But the solution is not unique in this case, we can also write $15=4^2-1^2$. – Peter Nov 4 '19 at 10:55

• Suppose , $$\ n\$$ is an odd prime number. $$x^2-y^2=n$$ means $$(x-y)(x+y)=n$$
Since $$\ x-y\le x+y\$$ holds, we can conclude that $$x-y=1$$ $$x+y=n$$ implying $$\ x=\frac{n+1}{2}\$$ , $$\ y=\frac{n-1}{2}\$$, which is the unique solution
• Suppose , we have the given solution. If we define $$\ k:=\frac{n-1}{2}\$$, we have the solution $$(k,k+1)$$. Since $$\ (k+1)^2-k^2=2k+1\$$ is odd , we can conclude that $$\ n\$$ is odd. If $$n$$ is odd and composite, there are odd numbers $$(a,b)$$ with $$\ 1 and $$\ ab=n\$$. Solving the system $$x+y=b$$ $$x-y=a$$ gives then a solution different from the given one, namely $$x=\frac{b+a}{2}$$ $$y=\frac{b-a}{2}$$ which differs from the given solution because $$\ 1 implies $$\ b-a.
• Note that for the criterion it is necessary that $0$ belongs to the natural numbers, otherwise $9$ would be a counterexample. – Peter Nov 4 '19 at 11:16