Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Is there any relatively efficient way to calculate integer solutions $x$ and $y$ to the equation $x^2 - y^2 = z$ for a fixed integer $z$?

May or may not be useful: $z$ is an odd composite number


share|improve this question

migrated from mathoverflow.net Jul 2 '13 at 1:49

This question came from our site for professional mathematicians.

Why not just ask if there's an efficient way to factor integers? –  Steven Landsburg Jul 2 '13 at 1:23

2 Answers 2

Write $z$ as $z=ab$. Hence, one solution for $x^2-y^2 = ab$ is $(x+y) = a \text{ and } x-y =b$.

I am sure you can take it from here.

share|improve this answer
We do not have uniqueness in the case of two primes, since the trivial factorization gives a solution. –  André Nicolas Jul 2 '13 at 1:55


If $z$ is odd, $z\pm 1$ i s even $\implies \frac{z\pm1}2$ is integer


If $z$ composite odd $=m\cdot n$(say), $m\pm n$ is even

$$m\cdot n=\left(\frac{m+n}2\right)^2-\left(\frac{m-n}2\right)^2$$

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.