Prove that $2xy\mid x^2+y^2-x$ implies $x$ is a perfect square.

Prove that $2xy\mid x^2+y^2-x$ implies $x$ is a perfect square.
My work:
$2xy\mid x^2+y^2-x \implies x^2+y^2-x=2xy\cdot k$
So,$x^2+y^2+2xy-x=(x+y)^2-x=2xy \cdot (k+1)$
And,$x^2+y^2-2xy-x=(x-y)^2-x=2xy \cdot (k-1)$
I found that for $x,y$ both odd, no solution exists. For $x$ even, and $y$ odd,no solution exists. Solution exists only for $x$ odd, $y$ even and $x$ even and $y$ even solution exists. Cannot do anything more. Please help!


Solution 1:

We use the following

Fact: A non-zero integer is a perfect square (by that I mean a number of the form $k^2$ or $-k^2$) if and only if in its prime factorization, the exponent of every prime factor is even.

Now let $p$ be any prime factor of $x$ and $k$ the exponent of $p$ in the prime factorization of $x$. If $k$ is even, there is nothing to show. So assume that $k$ is odd: $k=2j+1$.

Then $p^k|x|2xy|x^2+y^2-x$. Since $p^k|x^2-x$, it must also hold that $p^{2j+1}=p^k|y^2$. Since $y^2$ is a square, also $p^{k+1}=p^{2j+2}|y^2$.

But then $p^{k+1}|2xy|x^2+y^2-x$. But since $p^{k+1}|x^2+y^2$, it also follows that $p^{k+1}|x$. This is a contradiction (we assumed that $k$ is the exponent of $p$ in the factorization of $x$).

Since $p$ was an arbitrary prime factor, the exponents of all prime factors in the prime factorization of $x$ are even, i.e. $x$ is a square in the above sense.

Edit: Made precise what is meant by a square.

Solution 2:

Observe that $\ x\mid y^2\,$ and $\ x = (x\!-\!ky)^2+(1\!-\!k^2)y^2\ ( =\, x^2\!+y^2-2kxy,\ k\in\Bbb Z).\ $ Now apply

Theorem $\quad\, n\mid y^2\,$ and $\ n = z^2\!+ay^2\,\Rightarrow\, n\, =\, \pm (z,y)^2$

Proof $\ \pm n = (n,y^2) = (z^2\!+ay^2,y^2) = (z^2,y^2) = (z,y)^2\, $ by GCD Freshman's Dream $\ $ QED