I am looking at the sequence A002822 which essentially is equivalent to the twin prime sequence. Based on initial investigations, it has the following peculiar congruential structure.

Pattern A

For each prime $p\geq 5$, there exists a residue $a_p$ with $0\leq a_p <p$ such that if $n \bmod p = \pm a_p$ then $n$ does not belong to the sequence, except possibly if $n=a_p$. Otherwise, $n$ belongs to the sequence. The values of $a_p$, respectively for $p = 5, 7, 11, 13, 17, 19, 23, 29, 31$, are $a_p = 1, 1, 2, 2, 3, 3, 4, 5, 5$.

Pattern B

Besides these congruential exceptions, all values in A002822 are equidistributed modulo $p$, regardless of $p$.

Question: the original question was: can you prove pattern A? It has been positively answered, see the answer below.

Update: pattern C and new question

I found a new pattern and I am wondering if I should create a separate question about it. I am very interested in the answer.

Pattern C is simply the fact that $a_p=\lfloor \frac{p}{6}+\frac{1}{2}\rfloor$ (assuming $p\geq 5$ is prime). At this point, this is just an empirical observation, verified up to $p=181$.


Assuming patterns A and B are correct, we then get the following, unless I am wrong. Let $f(x)$ be the number of elements less than or equal to $x$ in the sequence in question. Then

$$f(x)\sim x\cdot \prod_{5\leq p \leq x}\frac{p-2}{p}\sim C\cdot\frac{x}{(\log x)^2} \mbox{ as } x\rightarrow\infty.$$

Note that we ignored the fact that some of the elements of the sequence are unaccounted for in the above formula: these are the elements for which $a_p$ is itself part of the sequence. Not a big deal, since the interest is to prove that the sequence has infinitely many elements (that is, there are infinitely many twin primes). Also, I am wondering if my asymptotic formula is compatible with the first Hardy-Littlewood conjecture. It is, except maybe for the constant $C$, unless I am mistaken.

Finally, could this lead to a non-probabilistic, non-heuristic argumentation to help prove the twin prime conjecture? Or is what I discovered already well-known, or wrong, or non amenable to anything useful?

  • $\begingroup$ I suspect that what you have found isn't wrong, but the difficulty arises in proving it... $\endgroup$
    – abiessu
    Jul 19, 2021 at 14:19
  • $\begingroup$ The fact that none of the elements of the sequence is congruent to $1$ or $4$ modulo $5$ is listed in the OEIS entry (and probably a trivial fact), but that's the only congruence being mentioned. $\endgroup$ Jul 19, 2021 at 14:25
  • 2
    $\begingroup$ Perhaps I am missing something. Surely the point is just that if $m$ is such that $6m\equiv \pm 1 \pmod p$ then of course $p$ divides one of $6m\pm 1$. For instance, if $p=5$, them we must avoid $m\equiv \pm 1 \pmod 5$. Is this the phenomenon you are speaking of? $\endgroup$
    – lulu
    Jul 19, 2021 at 14:30
  • $\begingroup$ Patterns won't solve the twin prime conjecture. No pattern that has yet been found, holds for larger twin prime pairs. This is the reason that the record size for a twin prime pair is "just" about $388\ 000$ digits (see here) , whereas the largest prime has more than $24.8$ million digits. $\endgroup$
    – Peter
    Jul 19, 2021 at 15:20
  • 1
    $\begingroup$ Remarkable that it has been shown that infinite many prime gaps do not exceed $246$. This is the best result that could be unconditionally proven. Not a single even prime gap is known to occur infinite many often, although almost surely , every even prime gap occurs infinite many often. A proof seems to be out of reach. $\endgroup$
    – Peter
    Jul 19, 2021 at 15:24

1 Answer 1


This answer addresses only the question of the correctness of the congruential structure observed by OP. The pattern he reports is provably correct.

Consider composite numbers of the form $n=36m^2-1$. $n \text{ is a semiprime } \iff (6m-1,6m+1) \in \mathbb P \iff 6m-1,6m+1 \text { are twin primes} \\ n \text{ is not a semiprime } \Rightarrow n \text{ has at least one prime factor } p_i<6m-1 $

Theorem: If $p_i=6a \pm 1 \le 6m-1 \land p_i \mid 36m^2-1$, then $m \equiv \pm a \bmod p_i$.

Case 1: $$p_i=6a-1 \Rightarrow s_j=\frac{36m^2-1}{p_i}=6(a+k)+1 \\ 36m^2-1=36a^2+36ak+6a-6a-6k-1 \\ 36m^2=36a^2+36ak-6k$$ Since $36$ divides the LHS, $36$ must divide the RHS, so $k=6n,\ n \ge 0$. Substituting $$m^2=a^2+6an-n \\ m^2-a^2=(m-a)(m+a)=n(6a-1)=n\cdot p_i \\ m \equiv \pm a \bmod p_i$$

Case 2: $$p_i=6a+1 \Rightarrow s_j=\frac{36m^2-1}{s_i}=6(a+k)-1 \\ 36m^2-1=36a^2+36ak-6a+6a+6k-1 \\ 36m^2=36a^2+36ak+6k$$ Since $36$ divides the LHS, $36$ must divide the RHS, so $k=6n,\ n > 0$. Substituting $$m^2=a^2+6an+n \\ m^2-a^2=(m-a)(m+a)=n(6a+1)=n\cdot p_i \\ m \equiv \pm a \bmod p_i$$

Corollary: $6m-1,6m+1 \in \mathbb P \iff \forall a<m,\ m\not \equiv \pm a \bmod p_i$. Note that this corollary excludes the case $a=m$, for which $m\equiv a$ with respect to any modulus. If $m=a$ (whence $n=0$ and $b=a$) is the only instance where $m \equiv \pm a \bmod p_i$, then $6m-1,6m+1$ are twin primes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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