Answer: q=7, p=19.
Note that q≤p, otherwise LHS <0, RHS >0. We have
p3−q3=pq3−1⇔p3+1=pq3+q3⇔(p+1)(p2−p+1)=q3(p+1)⇔p(p−1)=q3−1⇔p(p−1)=(q−1)(q2+q+1).
Since p(p−1)∤p, we have (q−1)(q2+q+1)∤p. But q−1∤p since q−1<p, so q2+q+1∤p, i.e., q2+q+1=kp, k∈N. Therefore
p(p−1)=(q−1)kp⇔p−1=k(q−1)⇔p=k(q−1)+1.
Then
q2+q+1=kp⇔q2+q+1=k2(q−1)+k.(1)
If k>3 we have
q2+q+1=k2(q−1)+k⟹(q−1)(q+2)+3=k2(q−1)+k⟹(q−1)(q+2)−k2(q−1)=k−3.
Hence,
(k−3)∣(q−1)⟹k≥q−1+3=q+2⟹(q−1)(q+2)=k2(q−1)+k−3≥(q+2)2(q−1)+q−1>(q−1)(q+2),which is impossible. So, we have no solutions when k>3. It remains toconsider three cases: k=1,2,3.
If k=1 from (1) we have q2+q+1=q. Hence q2+1=0, which is impossible.
If k=2 we have q2+q+1=4(q−1)+2, which gives q2−3q+3=0. It is easy to see that this equation has no real solution.
If k=3 from (1) we have
q2+q+1=9(q−1)+3⇔q2−8q+7=0.
It is easy to see that either q=1 or q=7. But 1 is not prime, so q=7, then p=3(q−1)+1=19.