Answer: (n;p)=(20;127).
It is easy to see that the given equality
p(p−1)=2(n3+1)(1)
does not hold for p=2 and positive integer n. So p≥3 is an odd prime number. Then (n+1)(n2−n+1) is divisible by p.
1. If (n+1)∤p, then n+1=kp for some positive integer k. In particular, n+1≥p. From (1) we have p(p−1)=2(n+1)(n2−n+1)≥2p(n2−n+1), and so p−1≥2n2−2n+2. Then n≥p−1≥2n2−2n+2 or 2n2−3n+2≤0, which is impossible.
2. Therefore n2−n+1∤p, i. e.
n2−n+1=kp(2)
for some positive integer k. Substituting (2) in (1), we obtain p−1=2k(n+1) or
p=2kn+2k+1.(3)
Substituting (3) in (2), we obtain n2−n+1=2k2n+2k2+k or
n2−(2k2+1)n−(2k2+k−1)=0.(4)
The discriminant D of this quadratic equation with respect to n is equal to D=(2k2+1)2+4(2k2+k−1) and D is evidently an odd number, D>(2k2+1)2; on the other hand D<(2k2+5)2 (indeed,
(2k2+1)2+4(2k2+k−1)<(2k2+5)2⟺4(2k2+k−1)<(4k2+6)⋅4⟺k−7<2k2.
Therefore, D=(2k2+1)2+4(2k2+k−1)=(2k2+3)2 (D must be perfect square, otherwise (4) has no integer roots). Thus,
4(2k2+k−1)=(2k2+3)−(2k2+1)=((4k2+4)⋅2⟺2k2+k−1=2k2+2
⟺k=3.
Then (4) has the form n2−19n−20=0, so n=20. From (3) we obtain p=2⋅3⋅20+2⋅3+1=127, and p is the prime number indeed.