# Patterns in twin primes

Hi guys so I was reading this question in an old textbook

Given a pair of twin primes, a and b

both are prime and b = a + 2

So when a > 5

So for example, a = 149 and b = 149 + 2 = 151

The product is 22499, so adding two gives 22501 and as this is prime this gives us our first prime that we need

There are 22 primes between 6 and 10000 that are expressed in the form ab + 2

So for example (149,151) is a pair of twin primes that is one of the 22

It then goes on to say that all of these primes are part of the same congruence class modulo 100

So I calculated it to find out they are all congruent to 1

Would someone be able to help me figure it out why this works?

The first thing I noted was that for any of the twin primes to work and be one of the 22, the units of the two primes have to add to 10 But I don't see how I could prove this works for all?

Thanks for any help guys!

• I feel these all share the same congruence because it's just an extension of fermat's little theorem, as they are twin primes they are always comprime and fermat's little theorem can be used which is why they all share the same congruence of 1
– user640961
Commented Feb 2, 2019 at 22:36

With $$a=2n-1$$ and $$b=2n+1$$, your prime number $$p=ab+2$$ has the form

$$p=(2n-1)(2n+1)+2=(2n)^2+1$$

Neither $$2n-1$$ nor $$2n+1$$ must be divisible by 5, so $$2n$$ can only be congruent 0, 2 or -2 modulo 5.

If $$2n \equiv \pm2$$ (mod 5), then $$p \equiv (2n)^2+1 \equiv 4+1 \equiv 0$$ (mod 5), which is of course not possible, since $$p$$ is a prime number (also greater than 5).

Therefore, it must be $$2n \equiv 0$$ (mod 5) and so $$(2n)^2 \equiv 0$$ (mod 25). Also, $$2n \equiv 0$$ (mod 2) and so $$(2n)^2 \equiv 0$$ (mod 4). Since 4 and 25 are relatively prime, it follows that $$(2n)^2 \equiv 0$$ (mod 4*25) and therefore $$p = (2n)^2+1 \equiv 1$$ (mod 100).

• Sorry this might be a really silly question but where do your a and b come from? For this question could I not just mention about fermat's little theorem? As they are twin primes they will all clearly be coprime?
– user640961
Commented Feb 3, 2019 at 10:49
• As written in the (your) original question, a and b (=a+2) are twin primes such that ab+2 is also a prime. You should have asked: “Where does your n come from?”. $a+1 = b-1$ must be even ($=2n$). Yes, a and b are coprime, but I can’t see any way to apply Fermat’s little theorem here. Commented Feb 3, 2019 at 12:16
• So for fermat's little theorem I was thinking (using 149 and 151 as my example) that 149^150 is congruent to 1 modulo 150, as they are all coprime they can all be expressed in this form? Sorry if that's silly number theory is not my strongpoint
– user640961
Commented Feb 3, 2019 at 12:26
• In your original question, you were not taking anything to any power. Apart from that, you probably mean $149^{150} \equiv 1$ (mod 151). Yes, and $151^{148} \equiv 1$ (mod 149). But how is this related to $149 \cdot 151+2 \equiv 1$ (mod 100)? Btw: $149^2 \equiv 1$ (mod 150), which is mostly because $149=150-1$. Commented Feb 3, 2019 at 13:15

Twin primes are always both odd (meaning they will have $$1,3,5,7,9)$$ as their final digit), and no number $$>5$$ ending in the digit $$5$$ can be a prime, since it will be divisible by $$5$$. So any pair twin primes (other than $$(5,7)$$ which was excluded by OP) will differ by $$2$$, and must have as their last digits one of $$(1,3),\ (7,9),\ (9,1)$$. Thus the product of such twin primes will end in the digit $$3$$ (for $$(1,3),\ (7,9)$$) or $$9$$ (for $$(9,1)$$). Twin primes whose product ends in $$3$$ cannot generate a prime by adding $$2$$, since that sum will end in the digit $$5$$ and thus be divisible by $$5$$. Therefore qualifying twin primes must end in the digits $$(9,1)$$. This explains OP's observation that the units place of such primes always add up to $$10$$.

All odd primes $$>3$$ have the form $$6n\pm 1$$, so any particular twin prime will be $$(6k-1),(6k+1)$$ for some specific $$k$$. If $$(6k-1)$$ ends in the digit $$9$$ and $$(6k+1)$$ ends in the digit $$1$$, then $$6k$$ ends in the digit $$0$$, meaning that $$5\mid k$$.

Let $$k=5m$$. Then each qualifying twin prime will have the form $$(30m-1),(30m+1)$$, and their product will be $$900m^2-1$$. Adding $$2$$ to this number gives $$900m^2+1$$. Since $$100\mid 900$$, $$900m^2+1 \equiv 1 \mod(100)$$. QED