Equation with solution in prime numbers

Solution 1:

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)$.

Solution 2:

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.