Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #33 Sep 16 2024 11:35:49
%S 3,4,5,6,7,12,13,19,25,26,27,28,43,44,48,49,59,63,64,69,88,89,112,116,
%T 142,143,147,148,151,152,181,182,206,211,212,224,225,229,234,235,236,
%U 253,261,264,276,285,286,287,301,302,313,314,322,332,336,352,384,389
%N Numbers k such that prime(k+2) - prime(k) = 6.
%H Robert Israel, <a href="/A361267/b361267.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimeTriplet.html">Prime Triplet</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Prime_triplet">Prime triplet</a>
%F a(n) = A000720(A007529(n)). - _Alois P. Heinz_, Mar 06 2023
%p q:= n-> is(ithprime(n+2)-ithprime(n)=6):
%p select(q, [$1..400])[]; # _Alois P. Heinz_, Mar 06 2023
%t Select[Range[400], Prime[# + 2] - Prime[#] == 6 &] (* _Michael De Vlieger_, Mar 06 2023 *)
%t PrimePi/@(Select[Partition[Prime[Range[400]],3,1],#[[3]]-#[[1]]==6&][[;;,1]]) (* _Harvey P. Dale_, Sep 16 2023 *)
%o (Clojure)
%o (defn next-prime [n]
%o (if (= n 2)
%o 3
%o (let [m (+ n 2)
%o t (-> n Math/sqrt int (+ 2))]
%o (if (some #(zero? (mod m %)) (range 2 t))
%o (next-prime m)
%o m))))
%o (def primes (lazy-seq (iterate next-prime 2)))
%o (defn triplet-primes-positions [n]
%o (->> primes
%o (take n)
%o (partition 3 1)
%o (map list (range))
%o (filter (fn [[i xs]] (= 6 (- (last xs) (first xs)))))
%o (map #(-> % first inc))))
%o (println (triplet-primes-positions 2000))
%o (Python)
%o from itertools import count, islice
%o from sympy import nextprime, prime
%o def A361267_gen(startvalue=1): # generator of terms >= startvalue
%o p = prime(m:=max(startvalue,1))
%o q = nextprime(p)
%o r = nextprime(q)
%o for k in count(m):
%o if r-p == 6:
%o yield k
%o p, q, r = q, r, nextprime(r)
%o A361267_list = list(islice(A361267_gen(),20)) # _Chai Wah Wu_, Mar 27 2023
%Y Cf. A000040, A000720, A007529, A022004, A022005.
%K nonn
%O 1,1
%A _Atabey Kaygun_, Mar 06 2023