Find all $$p,q$$ primes such that $$2q^p - p^q=7$$

My attempt:

First, I assumed $$q>p.$$ Then, I expressed $$q=p+x$$ for some $$x.$$ Then I took $$\pmod q$$ on both sides. Using Fermats little theorem and some modular arithmetic, I got the relation $$2x-7=kq$$ for some integer $$k.$$

I did the same for $$p$$ by assuming $$p>q, p=q+y$$ and got $$y-7=cp$$ for some integer $$c.$$

I don't know how to proceed next. Any help would be much appreciated.

• One solution, $(p,q)=(2,3):$ $$2\cdot 2^3-3^2=16-9=7.$$ Jul 13, 2023 at 5:01
• Another is $(p,q)=(5,3)$, $2\cdot5^3-3^5=7$. Jul 13, 2023 at 5:03
• We can see that $p$ can not be Even. When $p$ & $q$ are large & have large Difference , the 2 Powers will have a large Difference , exceeding 14. Even when we scale up 1 Power by 2 , the Difference will exceed 7. More-over , $p$ & $q$ can not be Equal. Hence , we must have Difference of 1. Checking $p=q+1$ & $p=q-1$ , we get the Solutions $2\cdot2^3-3^2=7$ & $2\cdot5^3-3^5=7$. When $p$ & $q$ are not large , we get the Solution with $p=1$ which is $2\cdot4^1-1^4=7$.
– Prem
Jul 13, 2023 at 5:29
• $q^p-p^q = 7 - q^p$, does that help? Jul 13, 2023 at 6:20

If $$p=2$$, we want $$2q^{2}-2^{q} = 7$$, which has no solutions. If $$p=3$$, we want $$2q^{3}-3^{q} = 7$$, which has solutions $$q=2, 5$$. If $$q = 2$$, we want $$2\cdot 2^{p}-p^{2} = 7$$, which has solution $$p = 3$$. All of the above cases can be proven through special cases and simple bounds.

Assume $$p\geq 5, q\geq 3$$. Clearly, $$p=q$$ has no solutions. First, assume $$q = p + x$$: $$2q^{p}-p^{q} = 2(p+x)^{p} - p^{p+x} = p^{p}\left(2\left(1 + \frac{x}{p}\right)^{p}-p^{x}\right)\leq p^{p}(2e^{x}-p^{x})$$ Because $$p\geq 5$$ and $$x\geq 2$$, we have $$2e^{x}-p^{x} \leq 2e^{2}-5^{2}< 0$$, so there are no solutions with $$q > p$$. Now, assume $$p = q + x$$: $$2q^{p}-p^{q}=2q^{q+x}-(q+x)^{q}=q^{q}\left(2q^{x}-\left(1+\frac{x}{q}\right)^{q}\right) \geq q^{q}(2q^{x}-e^{x})$$ Because $$q\geq 3$$ and $$x\geq 2$$, we have $$2q^{x}-e^{x}\geq 2\cdot 3^{2} - e^{2} > 7$$. Thus, there are no solutions with $$p > q$$, so the only solutions are $$\boxed{(p,q) = (3,2), (3,5)}$$

You've got the right idea. Similar to what you did, from Fermat's little theorem, for some integers $$m_1$$ and $$m_2$$, we get that

$$-p \equiv 7 \pmod{q} \;\;\to\;\; p + 7 = m_{1}q \tag{1}\label{eq1A}$$

$$2q \equiv 7 \pmod{p} \;\;\to\;\; 2q = m_{2}p + 7 \tag{2}\label{eq2A}$$

Since $$p$$ is odd, from \eqref{eq1A}, $$p = 3$$ gives that $$3 + 7 = 2(5) = m_{1}q$$. Thus, $$q$$ only may be $$2$$ or $$5$$, with both working. Next, $$p = 5$$ leads to $$5 + 7 = 2^2(3) = m_{1}q$$, but neither $$q = 2$$ nor $$q = 3$$ works.

As $$p = 7$$ doesn't work (because then $$q = 7$$), consider next $$p \gt 7$$. Since $$m_1 \ge 2$$ in \eqref{eq1A}, this means $$p \gt q$$. From \eqref{eq2A}, we thus get that $$m_2$$ must be a positive odd integer $$\lt 3$$, so it must be $$1$$, giving that $$2q = p + 7$$. This means that $$q \gt 7$$. From Given $a>b>2$ both positive integers, which of $a^b$ and $b^a$ is larger? (or several of its linked questions), we get

$$q \lt p \;\;\to\;\; q^p \gt p^q \tag{3}\label{eq3A}$$

The problem equation then leads to

$$2q^p - p^q = q^p + (q^p - p^q) \gt q^p \;\;\to\;\; 7 \gt q^p \tag{4}\label{eq4A}$$

which is not possible. Thus, $$\boxed{(p, q) \in \{(3, 2), (3, 5)\}}$$ are the only solutions.