OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Prime Triplet
Wikipedia, Prime triplet
FORMULA
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)
CROSSREFS
KEYWORD
nonn
AUTHOR
Atabey Kaygun, Mar 06 2023
STATUS
approved