Solution:
It is clear that p=q. We set
1+p+qpq−qp=r
and we have that
pq−qp=(r−1)(p+q)
From Fermat's Little Theorem we have
pq−qp≡−q(modp)
Since we also have that
(r−1)(p+q)≡−rq−q(modp)
from (3) we get that
rq≡0(modp)⇒p∣qr
hence p∣r, which means that p=r. Therefore, (3) takes the form
pq−qp=(p−1)(p+q)
We will prove that p=2. Indeed, if p is odd, then from Fermat's Little Theorem we have
pq−qp≡p(modq)
and since
(p−1)(p+q)≡p(p−1)(modq)
we have
p(p−2)≡0(modq)⇒q∣p(p−2)⇒q∣p−2⇒q≤p−2<p
Now, from (4) we have
pq−qp≡0(modp−1)⇒1−qp≡0(modp−1)⇒qp≡1(modp−1)
Clearly gcd(q,p−1)=1 and if we set k=ordp−1(q), it is well-known that k∣p and k<p, therefore k=1. It follows that
q≡1(modp−1)⇒p−1∣q−1⇒p−1≤q−1⇒p≤q
a contradiction.
Therefore, p=2 and (4) transforms to
2q=q2+q+2
We can easily check by induction that for every positive integer n≥6 we have 2n>n2+n+2. This means that q≤5 and the only solution is for q=5. Hence the only pair which satisfy the condition is (p,q)=(2,5).