How many solutions are there for the equation $x^y-y^x=x+y$ where $x$ and $y$ are prime?
I have found one $2^5-5^2=2+5$ and I'm not sure whether it's the only solution..

  • 2
    $\begingroup$ Any particular reason for limiting the question to primes? Isn't $(2,5)$ the only solution in natural numbers? Note that for all but very small numbers and with $y>x$ we have $x^y - y^x \geq x^{x+1} - (x+1)^x > 2x+1 = x + y$. $\endgroup$ – Adam Bailey Sep 30 '17 at 12:31
  • $\begingroup$ @AdamBailey I have found the equation by accident making other calculations on primes... $\endgroup$ – Widawensen Sep 30 '17 at 12:35

For more clarity set $x \mapsto p$, $y \mapsto q$ ($p$, $q$ prime nuumbers). So we want to find the solutions of $p^q - q^p = p + q$.

If $p = q$ the equation becomes $p^p - p^p = 2p \implies 0 = 2p$ which clearly has no solutions. So from now on assume $p \ne q$.

Modulo $p$ we have $-q^p \equiv q \pmod{p}$. But by Fermat little theorem $q^p \equiv q \pmod{p}$, since $p \ne q$. Then $q \equiv -q^p \equiv -q \pmod{p}$ or $2q \equiv 0 \pmod{p}$ or $p \mid 2q$. Again, since $p \ne q$ we have that $p \nmid q$, thus is must be $p \mid 2 \implies p = 2$.

Now we are left wih solving $2^q - q^2 = q + 2$. It can be shown by induction (I left it to you as an exercise) that $2^n > n^2 + n + 2$ for $n \ge 6$. Hence we can just check by hand the cases $q \in \{2, \: 3, \: 5\}$ and state that the only solution is, indeed, $(p, \: q) = (2, \: 5)$.

  • $\begingroup$ Thank you for both clear and convincing solutions. I had to accept one but both are equal and if it were a possibility to accept more than one solution on this site I would do that. $\endgroup$ – Widawensen Sep 29 '17 at 16:30

Suppose $p$ and $q$ are primes such that $p^q - q^p = p+q$; evidently we may assume $p\neq q$, since otherwise we get $p+q = 0$. Taking mod $p$ gives $$-q^p \equiv q \pmod{p}.$$ Since $p\neq q$, by Fermat's little theorem we also have $$q^{p} \equiv q \pmod{p} \implies q \equiv -q \pmod{p} \implies 2q \equiv 0 \pmod{p}.$$ Hence we have $p = 2$. Thus, $2^q = q^2+ q+2$. But for any $x>5$, we have $2^x > x^2 + x+ 2$. It follows that $q \le 5$. Checking all the possibilities for $q$ now reveals that $(p,q) = (2,5)$ is the only possible solution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.