# Pattern in twin primes

I recently noticed a pattern in twin primes. My questions are: does this pattern continue to hold indefinitely, and how would I prove it? Here's the pattern:

For the $$n$$th prime, there exists exactly $$n-2$$ twin prime pairs that can be created as follows:

$$p_n$$ is the $$n$$th prime,

$$P_p=\prod_{1

$$(p_nP_p-4, p_nP_p-2)$$

Here's what I've worked up to:

$$n=3$$ $$(p_n=5)$$ has $$3-2=1$$ twin prime pairs $$P_p=3$$ gives $$(15-4,15-2)=(11,13)$$

$$n=4$$ has 2 $$P_p=3$$ gives $$(17,19)$$ $$P_p=3\cdot 5$$ gives $$(101,103)$$

$$n=5$$ has 3 (29,31), (227,229), (1151,1153)

$$n=6$$ has 4 (191,193), (269,271), (2141,2143), (2999,3001)

$$n=7$$ has 5 (659,661), (2801,2803), (4637,4639), (23201,23203), (255251,255253)

Again, my questions are: does this pattern continue to hold indefinitely, and how would I prove it?

P.S. How about a pic of a brute force Mathematica script up to like 20?

• A proof that the pattern holds on forever would prove the twin-prime-conjecture. +1 for the discovery of the nice pattern. Feb 17 '16 at 19:01
• I'll polish this up later. Posted this on a cell phone during lunch break! Feb 17 '16 at 19:01
• @Peter Shhhh, lol. But yes, that's my ultimate goal. That would be SO awesome for someone with only an undergrad degree teaching 4th grade math! Feb 17 '16 at 19:04
• This definitely deserves a bounty eventually, but I'm a poor man with little reputation. Feb 17 '16 at 19:05

Do[
q = Prime[n] Times@@@Rest[Subsets[Table[Prime[k], {k, 2, n - 1}]]];
twin = Intersection[Select[q - 4, PrimeQ] + 2, Select[q - 2, PrimeQ]];
Print["n = ", n, " - ", twin, " - ", Length[twin]],
{n, 3, 20}]


The pattern breaks at $n=9$, since there are $8$ and not $7$ pairs of twin primes. For $n=20$ there are $2674$ pairs.

I have included the possibility of $m=2$, since you use it (although in the question you say $2<m<n$.)

• Awesome! Thanks! Too bad it doesn't continue exactly the same. Still, it's producing more rather than less. Also, $m=2$ would give an even number even after subtracting 2 or 4. Feb 17 '16 at 19:25
• @user3363795 Actually that would be $m=1$ since $p_2 = 3$ :). Feb 17 '16 at 19:28
• Oops, you're definitely right! Meant 2 itself not the 2nd prime. Editing now. Feb 17 '16 at 19:30
• In PARI/GP (free software), this function gives your pairs: f(n) = li=List();for(subset=1,1<<(n-2)-1,v=vecextract([2..n-1],subset);pp=prod(m=1,#v,prime(v[m]));a=prime(n)*pp-4;ispseudoprime(a)&&ispseudoprime(a+2)&&listput(li,[a,a+2]));Vec(li) The sequence giving number of pairs as a function of $n$, goes $1, 2, 3, 4, 5, 6, 8, 11, 27, 39, 53, 92, 179, 271, 492, 854, 1451, 2674, 4619, 8428, 14946, 27265, 49585, \ldots$. It is not in OEIS. Feb 17 '16 at 22:29
• @Jeppe Cool! Any way for me to submit it? Feb 18 '16 at 15:10

Julián Aguirre's answer is the definitive one, but I also want to give some insight on why this conjecture is kind of unreasonable (i.e. that one should expect it to become false by just doing a little computation).

Caveat: none of the following is proven — for instance, it hasn't been proven that there are infinitely many twin primes, so the probability of a number being part of a twin prime could in fact be $0$. But it is based on what number theorists call a heuristic argument based on the idea that primes are a reasonably good source of randomness and don't contain hidden correlations except for those that are easily explained (e.g. very few even numbers are prime). Heuristic arguments are frequently used to guess at what conjectures are plausible and which are implausible, and surprisingly they can be made quite precise.

There is a huge amount of flexibility in choosing $P_p$ (exponentially many choices), so one might expect that the failure of this conjecture will be that there are too many twin primes than predicted (and indeed this is what Julián discovered). How would we begin to analyze this?

Given a random large number $N$, the chances that $(N,N+2)$ is a twin prime are a little bit higher than $1/(\log N)^2$. In your case these numbers are not entirely random but they are specifically chosen to be indivisible by certain small primes ($2$ as well as the primes composing $P_p$), so we should really think of $1/(\log N)^2$ as a lower bound.

For a given $P_p = \prod_{p \in S_p} p$, the size of $1/(\log N)^2$ will depend on the specific set of primes $S_p$ that go into it: $\log N$ itself will be almost exactly equal to $\log p_n + \sum_{p \in S_p} \log p$. Since we're going for a lower bound, instead of summing up all the possibilities let's just take the worst case of all primes from $p_2$ to $p_n$. This gives (after some computation) $\log N \approx p_n$ so $1/(\log N)^2 \approx 1/p_n^2$.

But there are $2^{n-2}$ choices for $P_p$. Each of them has at least a $1/p_n^2$ chance of being part of a twin prime, so heuristically we would expect to find $2^{n-2}/p_n^2$ twin primes this way. Since $p_n$ only grows as fast as $n \log n$, the expected number of twin primes approaches infinity very quickly, so we should easily expect it to outstrip $n-2$ itself.

On the other hand, given that it has no reason to be true in general, it's nice that the pattern does hold up for $n=3, \ldots, 8$.

Starting from a prime $p_n$, the first candidate for a twin prime that the pattern generates is $3p_n-4$. If this formula does indeed produce prime numbers, then by iterating it, we have a simple way to generate arbitrarily large primes. That would be a big deal all by itself, as no such generator is known today. So we should be skeptical that the formula works...

Well, let's try it!

$5 \times 3 - 4 = 11$
$11 \times 3 - 4 = 29$
$29 \times 3 - 4 = 83$
$83 \times 3 - 4 = 245$

but $245$ is not prime.

• Perhaps I am misinterpreting your answer, but I don't think the OP meant that all subsets of primes between $p_2$ and $p_n$ are guaranteed to produce a prime, so why would you infer that $3p_n-4$ is prime? Feb 17 '16 at 19:27
• Yes, not everything it generates is prime, or a twin prime. However, if each prime generates at least one unique twin, then twins are infinite as primes are infinite. Feb 17 '16 at 19:28
• @ErickWong Ah, I though $P_p$ was meant to be one of the $n-2$ products of consecutive primes starting from $3$ up to a maximum $<p_n$. Feb 17 '16 at 21:22