TITLE: Bijection between twin primes and numbers $n$ such that $n^2-1$ has exactly four positive divisors
QUESTION [7 upvotes]: I'm working my way through Niven's Introduction to Number Theory, and the wording of the following problem is making me unsure of my answer:
Show that there is a one-to-one correspondence between twin primes and numbers $n$ such that $n^2-1$ has just four positive divisors. 
I felt an obvious bijection would be $f\colon A\rightarrow B\colon (p,p+2)\mapsto p+1$, where $A$ is the set of all pairs of twin primes, and $B$ is the set of all positive $n$ such that $n^2-1$ has only four positive divisors. $f$ is injective, and for any such $n$, if $n^2-1=(n-1)(n+1)$, has only four positive divisors, they must be $1,(n-1),(n+1),n^2-1$, implying that $n-1$ and $n+1$ are twin primes, and thus $(n-1,n+1)$ would be a suitable preimage. 
However, I assumed the wording of the problem meant I should show a bijection from unordered pairs of twin primes to positive integers, but I'm not sure if the problem intended for me to find a bijection that takes a single prime that happens to be a twin prime, to any such $n$, not necessarily positive which is problematic since both $n$ and $-n$ give the same $n^2-1$. Have I interpreted this problem correctly? If not, do other bijections exist with the differing domains and ranges I mentioned above?

REPLY [2 votes]: 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,