# Finding all pairs of integer solutions to ${x^y = (x+y)^2}$

How do I find all solutions for $${x^y = (x+y)^2}$$, where $$x$$ and $$y$$ are positive integers and at least one of them is prime.

For example, $${64 = 2^6 = (2+6)^2}$$

A friend of mine pointed out that $$x|y^2$$ then $$x^2|y^2$$, so, when $$x$$ is prime and $$y$$ is not prime, we can write $$y=xk$$. Thus $$x^{xk} = x^2 (1+k^2)$$ and $$x^{xk-2} = (1+k^2)$$.

• $y$ must be even. Oct 8, 2021 at 15:35
• That has nothing to do with what I said. I was just thinking maybe this can be useful. If you just take the square root on both sides then you see that the $RHS$ is an integer while the $RHS$ is $x^\frac{y}{2}$ which would be an integer if $y$ is even. Oct 8, 2021 at 15:48

I'll ignore the "prime" requirement. It just spoils the fun. And I assume positive and negative integers.

x=0 is not possible. $$0^y$$ is only defined if $$y>0$$, but then $$(0 + y)^2 > 0 = 0^y$$.

If y < 0 then $$x^y$$ is not an integer unless $$x = ±1$$ and $$x^y = ±1$$. Since $$x^y = (x+y)^2 ≥ 0$$ we must have $$x^y = +1$$ and $$x+y = ± 1$$. $$x = -1$$ is not possible because it makes $$x + y ≤ -2$$ and $$(x+y)^2 ≥ 4$$. $$x=1$$ implies $$x+y = ±1$$, therefore $$y=0$$ or $$y=-2$$, so $$1^{-2} = (1-2)^2 = 1$$ is the only solution with $$y<0$$.

If $$y=0$$ then $$x^y = 1$$, so $$(x+0)^2 = 1$$ so $$x = ±1$$. $${±1}^0 = (±1 + 0)^2 = 1$$.

If $$y=1$$ then $$x^y = x = (x+1)^2$$. We must have $$x>0$$, and any $$x > 0$$ is less than $$(x+1)^2$$, so no solution.

If $$y=2$$ then $$x^y = x^2 = (x+2)^2$$, so $$x + 2 = ±x$$. This is the case only for x = -1, y = 2: $${-1}^2 = (-1 + 2)^2 = 1$$.

If $$x = ±1$$ then $$x^y$$ must be 1, so $$x+y = ±1$$. Not possible with $$y ≥ 3$$.

If $$y ≥ 3$$ and $$|x| ≥ 2$$ then $$x^y$$ grows faster than $$(x + y)^2$$; the only values where $$(x+y)^2 ≥ x^y$$ are:

$$2^3 = 8 < 25 = (2+3)^2$$
$$2^4 = 16 < 36 = (2+4)^2$$
$$2^5 = 32 < 49 = (2+5)^2$$
$$2^6 = 64 = 64 = (2+6)^2$$
$$3^3 = 27 < 36 = (3+3)^2$$

and the only solution is $$2^6 = (2+6)^2 = 64$$.

Summary: The only solutions with positive or negative integers are $$1^{-2} = (1-2)^2 = 1$$, $$1^0 = (1+0)^2 = 1$$, $${-1}^0 = (-1 + 0)^2 = 1$$, $${-1}^2 = (-1 + 2)^2 = 1$$, and $$2^6 = (2+6)^2 = 64$$.

• Is there a more "closed form" solution? I was expecting to see some modular arithmetic for some reason. Great solution anyways! Oct 8, 2021 at 15:33
• @V.M. You might be able to extend this to real x. Oct 8, 2021 at 15:40

This is not an answer. This is a clarification to a comment I did to the OP.

$$y$$ must be even if $$x$$ is not a perfect square because:

Since $$y$$ is an integer there are two possibilities, either $$y=2k$$ or $$y=2k+1$$. If $$y=2k+1$$(odd) then

$$x^y=x^{2k+1}=(x+2k+1)^2$$

$$x^\frac{2k+1}{2}=x+2k+1$$

$$x^k\sqrt{x}=x+2k+1$$

Notice that here the $$RHS$$ is an integer and the $$LHS$$ would also be an integer if $$x$$ is a perfect square otherwise the $$LHS$$ would not be an integer which is a contradiction.

This means that if $$x$$ is not a perfect square then $$y$$ is even.