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.

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

Original entry on oeis.org

2, 23, 37, 47, 53, 67, 79, 83, 89, 97, 113, 127, 131, 157, 163, 167, 173, 211, 223, 233, 251, 257, 263, 277, 293, 307, 317, 331, 337, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 439, 443, 449, 457, 467, 479, 487, 491, 499, 503, 509, 541, 547, 557, 563
Offset: 1

Views

Author

Keywords

Comments

Almost all primes are a member of this sequence by Brun's theorem.
A010051(a(n))*(1-A164292(a(n))) = 0; complement of A001097 with respect to A000040. - Reinhard Zumkeller, Mar 31 2010

Examples

			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
		

References

  • Richard L. Francis, "Isolated Primes", J. Rec. Math., 11 (1978), 17-22.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndices)
    a007510 n = a007510_list !! (n-1)
    a007510_list = map (+ 1) $ elemIndices (0, 1, 0) $
    zip3 (drop 2 a010051_list) a010051_list (0 : 0 : a010051_list)
    -- Reinhard Zumkeller, Sep 16 2014
    
  • Magma
    [p: p in PrimesUpTo(1000)| not IsPrime(p-2) and not IsPrime(p+2)]; // Vincenzo Librandi, Jun 20 2014
    
  • Maple
    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
    isA007510 := proc(n) isprime(n) and not isprime(n+2) and not isprime(n-2) ; simplify(%) ; end proc:
    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
  • Mathematica
    Transpose[Select[Partition[Prime[Range[100]], 3, 1], #[[2]] - #[[1]] != 2 && #[[3]] - #[[2]] != 2 &]][[2]] (* Harvey P. Dale, Mar 01 2001 *)
    Select[Prime[Range[4,100]],!PrimeQ[ #-2]&&!PrimeQ[ #+2]&] (* Zak Seidov, May 07 2007 *)
    Select[Prime[Range[150]],NoneTrue[#+{2,-2},PrimeQ]&] (* Harvey P. Dale, Dec 26 2022 *)
  • PARI
    forprime(x=2,1000,if(!isprime(x-2)&&!isprime(x+2),print(x))) \\ Zak Seidov, Mar 23 2009
    
  • 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
    
  • Python
    from sympy import nextprime
    def aupto(limit):
      n, p, q = 1, 2, 3
      alst, non_twins, twins = [], [2], [3]
      while True:
        p, q = q, nextprime(q)
        if q - p == 2:
          if p != twins[-1]: twins.append(p)
          twins.append(q)
        else:
          if p != twins[-1]: non_twins.append(p)
        if q > limit: return non_twins
    print(aupto(563)) # Michael S. Branicky, Feb 23 2021
  • 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
    

Formula

A010051(a(n)-2) + A010051(a(n)+2) = 0, n > 2. - Reinhard Zumkeller, Sep 16 2014
a(n) = prime(A176656(n)). - R. J. Mathar, Feb 19 2017
a(n) ~ n log n. - Charles R Greathouse IV, Aug 21 2017

Extensions

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