Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I decided to try getting a test for a "twinness" of a prime via Wilson's theorem.

Wilson's theorem says that integer $n > 1$ is a prime iff $$(n-1)! \ \equiv -1 \pmod n $$

Now, if both $n$ and $n+2$ are prime, we get two equations:

\begin{cases} (n-1)! \ \equiv -1 \pmod n & (1)\\ (n+1)! \ \equiv -1 \pmod{n+2} & (2) \\ \end{cases}

The equation (1) means that there exists integer $k$ such that $$(n-1)! = k n-1$$ By writing the equation (2) such that there is integer $v$ that $$(n+1) n (n-1)! = -1+ v(n+2)$$ and then replacing $(n-1)!$ in (2) from (1), we get: $$(n+1) n (k n-1) = -1+ v(n+2).$$

This can be written as $$k(n^3+n^2)+v(-2-n)=n^2+n-1 \ \ \ \ (3)$$

So, I would think that $n$ is the first of twin of primes iff there exists integers $k$ and $v$ that (3) is true.

But, take $n=7.$

Now we get $$392 k = 55 + 9 v$$ which has solution $\{k = 2, v = 81\}.$

This shouldn't be possible. Where is the error?

share|cite|improve this question
One can write \begin{cases} (n-1)! \ \equiv -1 \pmod n & (1)\\ (n+1)! \ \equiv -1 \pmod{n+2} & (2) \\ \end{cases} or \begin{cases} (n-1)! \ \equiv -1 \bmod n & (1)\\ (n+1)! \ \equiv -1 \bmod n+2 & (2) \\ \end{cases} by using \pmod or \bmod, without writing \text{mod} and then manually adding spaces. (If \pmod is used, then you can write \pmod n and you see $\pmod n$, but if you write \pmod n+2, you'll see $\pmod n+2$, so you need to write \pmod{n+2} to make sure the "+2" is included, getting $\pmod{n+2}$.) – Michael Hardy Oct 20 '13 at 20:56
You have a typo in (3): It should be $v(-2-n)$ rather than $v(2-n)$. – Andrés E. Caicedo Oct 20 '13 at 20:57
Thank you for the edit, makes it clearer. – Valtteri Oct 20 '13 at 20:57
@AndresCaicedo True, thanks, will fix. – Valtteri Oct 20 '13 at 21:00
It's nice to see that you reduced the twin prime conjecture to the infinitely-many-solutions-ness of a polynomial equation in three variables. – Patrick Da Silva Oct 20 '13 at 21:06
up vote 2 down vote accepted

Your logic is not reversible, so the congruence you derive is a necessary condition, not an if-and-only-if. For instance, there is no hope of deducing (1) from (3), because you have eliminated any information there was about $(n-1)!$ from (3).

share|cite|improve this answer
I see and understand. So by taking the stuff from the first one and then replacing the (n-1)! in the second one I lost the connection to the first factorial completely. Thanks. – Valtteri Oct 20 '13 at 21:11

Your equation $(3)$ had an arithmetic error, it should read:


Are you aware of the reformulation of Wilson's theorem for twin primes? The prime pages list it as follows:

$$4[(n-1)!+1]\equiv -n\mod n(n+2)$$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.