First, the small stuff: p=2 and p=3
If p=2 then 2^5+2^3+2 = 42 = 7^2-7. 7 is prime so (p,q)=(2,7) is a solution.
If p=3 then 3^5+3^3+2 = 272 = 17^2-17. 17 is prime so (p,q)=(3,17) is a solution.
So now lets look at "large" primes p (primes 5 and bigger).
Subtract 2 from each side and factor: p^3 * (p^2+1) = (q+1) * (q-2).
The two terms p^3 and p^2+1 on the left side are coprime. Also we have p^2+1 mod 3 is never zero, so the left side is cannot have 3 as a factor.
The two terms q-2 and q+1 on the right side differ by 3 so if they have a common factor that factor must be 3. However they are being equated to an expression that is coprime to 3. Then because we are factoring over integers we must conclude q-2 and q+1 are coprime.
Because q+1 and q-2 are coprime, p can divide only one of them. Then with p^3>p^2+1 we must have p^3 divides the larger term q+1. Then q-2 is at most p^2+1.
From here some inequalities can be constructed: q+1>p^3 implies q>p^3-1and p^2+1>q-2 implies p^2+3>q. Then p^2+3>q>p^3-1, which makes p^2+3>p^3-1.
p^2+3>p^3-1 can be rearranged and factored as 0>(p-2)*(p^2+p+2). p^2+p+2 is always positive, so then the inequality is true for only p<2. But this contains none of the "large" primes. Thus there are no more solutions.
The pairs of primes (p,q) such that p^5+p^3+2=q^2-q are (2,7) and (3,17).
Edited on April 2, 2023, 9:58 pm