Quote by shmoe
Notice this has nothing to do with them being twin primes. This is almost the same as the proof of the LucasLehmer test. I think the reverse implication might be true as well, if 8n+5 divides S_(4n+3) then 8n+5 is prime (same for 7), but I haven't worked out the details.

Yes it works for all primes. It is interesting because if 2 is a square modulus n then S_((n1)/2) = 0 modulus n otherwise S_((n+1)/2) = 0 mod n. For twin primes thes are the same numbers. The converse is not true. One example is n = 19*59 also works.