login
A361267
Numbers k such that prime(k+2) - prime(k) = 6.
1
3, 4, 5, 6, 7, 12, 13, 19, 25, 26, 27, 28, 43, 44, 48, 49, 59, 63, 64, 69, 88, 89, 112, 116, 142, 143, 147, 148, 151, 152, 181, 182, 206, 211, 212, 224, 225, 229, 234, 235, 236, 253, 261, 264, 276, 285, 286, 287, 301, 302, 313, 314, 322, 332, 336, 352, 384, 389
OFFSET
1,1
LINKS
Eric Weisstein's World of Mathematics, Prime Triplet
Wikipedia, Prime triplet
FORMULA
a(n) = A000720(A007529(n)). - Alois P. Heinz, Mar 06 2023
MAPLE
q:= n-> is(ithprime(n+2)-ithprime(n)=6):
select(q, [$1..400])[]; # Alois P. Heinz, Mar 06 2023
MATHEMATICA
Select[Range[400], Prime[# + 2] - Prime[#] == 6 &] (* Michael De Vlieger, Mar 06 2023 *)
PrimePi/@(Select[Partition[Prime[Range[400]], 3, 1], #[[3]]-#[[1]]==6&][[;; , 1]]) (* Harvey P. Dale, Sep 16 2023 *)
PROG
(Clojure)
(defn next-prime [n]
(if (= n 2)
3
(let [m (+ n 2)
t (-> n Math/sqrt int (+ 2))]
(if (some #(zero? (mod m %)) (range 2 t))
(next-prime m)
m))))
(def primes (lazy-seq (iterate next-prime 2)))
(defn triplet-primes-positions [n]
(->> primes
(take n)
(partition 3 1)
(map list (range))
(filter (fn [[i xs]] (= 6 (- (last xs) (first xs)))))
(map #(-> % first inc))))
(println (triplet-primes-positions 2000))
(Python)
from itertools import count, islice
from sympy import nextprime, prime
def A361267_gen(startvalue=1): # generator of terms >= startvalue
p = prime(m:=max(startvalue, 1))
q = nextprime(p)
r = nextprime(q)
for k in count(m):
if r-p == 6:
yield k
p, q, r = q, r, nextprime(r)
A361267_list = list(islice(A361267_gen(), 20)) # Chai Wah Wu, Mar 27 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Atabey Kaygun, Mar 06 2023
STATUS
approved