I developed a twin prime sieve and would like to know if there is a well known equivalent. Pardon my lack of proper notation. Feedback on how to format this properly would also be appreciated.
let K = some natural number
M = 6*K^2
N = 6*M
S = {1,2,3,...M}
forall k in {1,2,3,...K}
p,q = 6*k-1, 6*k+1
A = {a : -k (mod p), a <= M}
B = {b : k (mod p), b <= M}
C = {c : -k (mod q), c <= M}
D = {d : k (mod q), d <= M}
S = S - (A+B+C+D)
T = {(6*k-1, 6*k+1) for k in S}
I have a simple python implementation of this here. A sample run for K = 2 looks like this;
K: 2 M: 24 N: 144
S: set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])
k: 1
p,q: 5 , 7
A: [4, 9, 14, 19, 24]
B: [6, 11, 16, 21]
C: [6, 13, 20]
D: [8, 15, 22]
S: set([1, 2, 3, 5, 7, 10, 12, 17, 18, 23])
k: 2
p,q: 11 , 13
A: [9, 20]
B: [13, 24]
C: [11, 24]
D: [15]
S: set([1, 2, 3, 5, 7, 10, 12, 17, 18, 23])
Twin Primes <= 144 :
[(5, 7), (11, 13), (17, 19), (29, 31), (41, 43), (59, 61), (71, 73), (101, 103), (107, 109), (137, 139)]
k=1andp=5the values in A, while they are all-1 (mod 5)actually represent n which are all+1 (mod 5). Thus4represents6*4+1 = 25. Similar for B, which are all1 (mod 5)but represent n which are-1 (mod 5). Hence 6 represents6*6-1 = 35. This, and a few other tricks, can be used to optimize the algorithm. – CAB Jun 28 '17 at 20:01