First, suppose on the contrary that S is finite, then S={p1,p2,…,pk} for k=∣S∣. It is easy to check that 2,3∈/S.
Consider number N=(p1−1)(p2−1)⋯(pk−1) and M=2N2+1−3N. For some p∈S, by Euler's theorem, we have
2p−1≡1(modp) and 3p−1≡1(modp).
Then 2N2+1=2⋅2N2=2⋅(2p−1)p−1N2≡2(modp) and 3N≡(3p−1)p−1N≡1(modp). Hence, M≡2−1=1(modp). So by the Chinese remainder theorem, we also have M≡1(modN) and M>2 then M has some prime divisor that differs from p1,p2,…,pk, which is a contradiction.
Thus, S has infinitely many elements.
To prove the second part, just consider some prime p such that there does not exist x∈Z such that either x2≡2(modp) or x2≡3(modp). Indeed, suppose that for such prime p, p∈S then we have two cases:
- If n is even then 2⋅2n2≡3n(modp), which can be written as 2x2≡y2(modp) for some x,y coprime to p. Then take x′ such that xx′≡1(modp), so 2≡(x′y)2(modp), contradicting that 2 is not a quadratic residue modulo p.
- If n is odd then we have a similar argument.
Thus, we just need to show that there are infinitely many such primes. By Euler's criterion about quadratic residues, we need
(p2)=(p3)=−1 and (p2)≡22p−1(modp),(p3)≡32p−1(modp).
So we can see that p≡3,5(mod8) and p≡2(mod3), which implies that we can take any prime of the form p=24k+5 or p=24k+11. Dirichlet's theorem states that the primes of the form an+b for any coprime positive integers a,b are infinite, so we finish our proof. □