Bijection between twin primes and numbers $n$ such that $n^2-1$ has exactly four positive divisors
I did this same problem for a class on number theory, the book omits a constraint that n>3 since 3^2 -1 = 8 which is divisible by 1,2,4,8 and 4 is not prime it does however hold for all n>3. Intuitively this is a consequence of the fact that 2 is the only even prime and that the product of three consecutive integers is divisible by 6 (n-1 being divisible by two would typically eliminate its candidacy for being prime EXCEPT for the n-1 = 2 case). Proving that a one-to-one correspondence exists is done by proving a that there is an iff statement relating (n-1),(n+1) being prime and (n-1)(n+1) having 4 dividers. Since this would imply that the set of all n such that n^2-1 has 4 dividers is equal to the set of n s.t. (n-1),(n+1) are prime and the function mapping a set back to itself is a trivial bijective map.
One direction is pretty easy, (n-1),(n+1) prime => s = (n-1)(n+1) = p1*p2 therefore s has 4 dividers, 1,s,p1, and p2.
The other direction is left for you to figure out,