cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A136207 Primes p such that p-6 or p+6 is prime.

This page as a plain text file.
%I A136207 #12 Feb 16 2025 08:33:07
%S A136207 5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,73,79,83,89,97,101,
%T A136207 103,107,109,113,131,137,151,157,163,167,173,179,191,193,197,199,223,
%U A136207 227,229,233,239,251,257,263,269,271,277,283,307,311,313,317,331,337
%N A136207 Primes p such that p-6 or p+6 is prime.
%C A136207 Either or both of (p-6) and (p+6) is/are prime. - _Harvey P. Dale_, Jun 22 2019
%H A136207 Lei Zhou, <a href="/A136207/b136207.txt">Table of n, a(n) for n = 1..10000</a>
%H A136207 Eric Weisstein's World of Math, <a href="https://mathworld.wolfram.com/SexyPrimes.html">Sexy Primes</a>. [The definition in this webpage is unsatisfactory, because it defines a "sexy prime" as a pair of primes.- _N. J. A. Sloane_, Mar 07 2021]
%H A136207 Wikipedia, <a href="http://en.wikipedia.org/wiki/Sexy_prime">Sexy Primes</a>
%p A136207 isA136207 := proc(n)
%p A136207     if isprime(n) then
%p A136207         if isprime(n+6) or isprime(n-6) then
%p A136207             true;
%p A136207         else
%p A136207             false;
%p A136207         end if;
%p A136207     else
%p A136207         false ;
%p A136207     end if;
%p A136207 end proc:
%p A136207 A136207 := proc(n)
%p A136207     option remember;
%p A136207     local a;
%p A136207     if n = 1 then
%p A136207         5 ;
%p A136207     else
%p A136207         a := nextprime(procname(n-1)) ;
%p A136207         while true do
%p A136207             if isA136207(a) then
%p A136207                 return a;
%p A136207             else
%p A136207                 a := nextprime(a) ;
%p A136207             end if;
%p A136207         end do:
%p A136207     end if;
%p A136207 end proc:
%p A136207 seq(A136207(n),n=1..80) ; # _R. J. Mathar_, Jun 10 2024
%t A136207 dd = 6; DistancePrimesQ1 = (PrimeQ[ # ] && PrimeQ[ # + dd]) &; DistancePrimesQ2 = (PrimeQ[ # ] && PrimeQ[ # - dd] && (# > dd)) &; DistancePrimesQQ = (DistancePrimesQ1[ # ] || DistancePrimesQ2[ # ]) &; DistancePrimes = Select[Range[ # ], DistancePrimesQQ] &; DistancePrimes[1000]
%t A136207 Alternative by _Lei Zhou_:
%t A136207 p = 3; Table[While[p = NextPrime[p]; ! (PrimeQ[p - 6] || PrimeQ[p + 6])]; p, {n, 1, 100}]
%t A136207 Select[Prime[Range[3,100]],AnyTrue[#+{6,-6},PrimeQ]&] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Jun 22 2019 *)
%Y A136207 Cf. A023201, A046117, A140546 (complement).
%K A136207 nonn
%O A136207 1,1
%A A136207 _Carlos Alves_, Dec 21 2007