login
Single (or isolated or non-twin) primes: Primes p such that neither p-2 nor p+2 is prime.
(Formerly M2130)
98

%I M2130 #85 May 11 2023 10:26:50

%S 2,23,37,47,53,67,79,83,89,97,113,127,131,157,163,167,173,211,223,233,

%T 251,257,263,277,293,307,317,331,337,353,359,367,373,379,383,389,397,

%U 401,409,439,443,449,457,467,479,487,491,499,503,509,541,547,557,563

%N Single (or isolated or non-twin) primes: Primes p such that neither p-2 nor p+2 is prime.

%C Almost all primes are a member of this sequence by Brun's theorem.

%C A010051(a(n))*(1-A164292(a(n))) = 0; complement of A001097 with respect to A000040. - _Reinhard Zumkeller_, Mar 31 2010

%D Richard L. Francis, "Isolated Primes", J. Rec. Math., 11 (1978), 17-22.

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H T. D. Noe, <a href="/A007510/b007510.txt">Table of n, a(n) for n = 1..10000</a>

%H Jens Kruse Andersen, Paul Underwood and Pierre Cami, <a href="/A007510/a007510.txt">Chen prime with 70301 digits</a>, digest of 3 messages in primeform Yahoo group, Oct 7, 2005.

%H Jens Kruse Andersen, <a href="http://www.worldofnumbers.com/YPFM6481.htm">Yahoo Primeform Group Message 6481 dd. Oct 7, 2005</a>, reconstruction in html.

%H Ernest G. Hibbs, <a href="https://www.proquest.com/openview/4012f0286b785cd732c78eb0fc6fce80">Component Interactions of the Prime Numbers</a>, Ph. D. Thesis, Capitol Technology Univ. (2022), see p. 33.

%H Omar E. Pol, <a href="http://www.polprimos.com">Determinacion geometrica de los numeros primos y perfectos</a>.

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Isolated_prime">Isolated prime</a>

%F A010051(a(n)-2) + A010051(a(n)+2) = 0, n > 2. - _Reinhard Zumkeller_, Sep 16 2014

%F a(n) = prime(A176656(n)). - _R. J. Mathar_, Feb 19 2017

%F a(n) ~ n log n. - _Charles R Greathouse IV_, Aug 21 2017

%e All primes congruent to 7 mod 15 are members, except for 7. All terms of A102723 are members, except for 5. - _Jonathan Sondow_, Oct 27 2017

%p with(numtheory): for i from 1 to 150 do p:=ithprime(i): if(not isprime(p+2) and not isprime(p-2)) then printf("%d, ",p) fi od: # Pab Ter

%p isA007510 := proc(n) isprime(n) and not isprime(n+2) and not isprime(n-2) ; simplify(%) ; end proc:

%p A007510 := proc(n) if n = 1 then 2; else for a from procname(n-1)+1 do if isA007510(a) then return a; end if; end do; end if; end proc: # _R. J. Mathar_, Apr 26 2010

%t Transpose[Select[Partition[Prime[Range[100]], 3, 1], #[[2]] - #[[1]] != 2 && #[[3]] - #[[2]] != 2 &]][[2]] (* _Harvey P. Dale_, Mar 01 2001 *)

%t Select[Prime[Range[4,100]],!PrimeQ[ #-2]&&!PrimeQ[ #+2]&] (* _Zak Seidov_, May 07 2007 *)

%t Select[Prime[Range[150]],NoneTrue[#+{2,-2},PrimeQ]&] (* _Harvey P. Dale_, Dec 26 2022 *)

%o (UBASIC) 10 'primes using counters 20 N=3:print "2 ";:print "3 ";:C=2 30 A=3:S=sqrt(N) 40 B=N\A 50 if B*A=N then 55 55 Q=N+2:R=N-2: if Q<>prmdiv(Q) and N=prmdiv(N) and R<>prmdiv(R) then print Q;N;R;"-";:stop:else N=N+2:goto 30 60 A=A+2 70 if A<=sqrt(N) then 40:stop 81 C=C+1 100 N=N+2:goto 30 ' _Enoch Haga_, Oct 08 2007

%o (PARI) forprime(x=2,1000,if(!isprime(x-2)&&!isprime(x+2),print(x))) \\ _Zak Seidov_, Mar 23 2009

%o (PARI) list(lim)=my(v=List([2]),p=3,q=5); forprime(r=7,lim, if(q-p>2 && r-q>2, listput(v,q)); p=q; q=r); p=precprime(lim); if(p<=lim && p-precprime(p-2)>2 && nextprime(p+2)-p>2, listput(v,p)); Vec(v) \\ _Charles R Greathouse IV_, Aug 21 2017

%o (Magma) [p: p in PrimesUpTo(1000)| not IsPrime(p-2) and not IsPrime(p+2)]; // _Vincenzo Librandi_, Jun 20 2014

%o (Haskell)

%o import Data.List (elemIndices)

%o a007510 n = a007510_list !! (n-1)

%o a007510_list = map (+ 1) $ elemIndices (0, 1, 0) $

%o zip3 (drop 2 a010051_list) a010051_list (0 : 0 : a010051_list)

%o -- _Reinhard Zumkeller_, Sep 16 2014

%o (Python)

%o from sympy import nextprime

%o def aupto(limit):

%o n, p, q = 1, 2, 3

%o alst, non_twins, twins = [], [2], [3]

%o while True:

%o p, q = q, nextprime(q)

%o if q - p == 2:

%o if p != twins[-1]: twins.append(p)

%o twins.append(q)

%o else:

%o if p != twins[-1]: non_twins.append(p)

%o if q > limit: return non_twins

%o print(aupto(563)) # _Michael S. Branicky_, Feb 23 2021

%Y Cf. A083370, A124582, A134099, A134100, A134101, A010051, A102723.

%K nonn,easy,nice

%O 1,1

%A _N. J. A. Sloane_, _Robert G. Wilson v_

%E More terms from Pab Ter (pabrlos2(AT)yahoo.com), Nov 11 2005