# Integer solutions to a Diophantine Equation

How would I find all integer solutions algebraically for $$x^2-2xy+n=0$$ if $$n$$ is known and a solution is known, but without factoring $$n$$. Also, is it possible to know how many integer solutions exist for this equation for a known $$n$$, again without factoring $$n$$.

• cannot be done. From $n = x (2y-x),$ any solution gives factors, and the collection of all solutions gives a complete factoring of $n$ – Will Jagy Feb 6 at 21:40
• I see, but what about the number of solutions – James Feb 6 at 21:41
• If $n$ is odd, the number of solutions is the same as the number of divisors of $n$. If $n=2^km$, with $k\ge1$ and $m$ odd, then $x$ must have the form $2^hz$, where $0<h<k$ and $z\mid m$. In particular there is no solution if $k=1$. – egreg Feb 6 at 22:45
• So without factoring there's no way to know? – James Feb 6 at 22:46

Above equation shown below:

$$x^2-2xy+n=0$$ ------$$(A)$$

Equation $$(A)$$ has solution:

$$(x,y,n)=[(p),(p+2),(p^2+4p)]$$

• How would you find $p$? – James Feb 7 at 11:19

$$2 x y - x^2 = n$$ $$x (2y - x) = n$$ $$a * b = n$$ $$2 y - a = b$$ $$y = (a + b) / 2$$ $$(x, y, n) = (a, (a + b) / 2, ab)$$ $$n = -15 * (-1) = -5 * (-3) = ... = 3 * 5 = 5 * 3 = 15 * 1$$ $$1) a = -15, b=-1; (x,y,n)=(-15, -8,15),$$ $$...$$ $$n = 2 (2 m - 1) - no$$ $$n = 6 = 2 * 3 - no$$

• Is there any way to get answers without knowing $a$ or $b$ if a solution is known? – James Feb 7 at 11:21