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.

Previous Showing 11-20 of 24 results. Next

A051700 Distance from n to closest prime that is different from n.

Original entry on oeis.org

2, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 3, 2, 1, 6, 1, 2, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 4, 1, 2, 3, 2, 1, 6, 1, 2, 3, 4, 3, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1
Offset: 0

Views

Author

Keywords

Examples

			Closest primes to 0,1,2,3,4 are 2,2,3,2,3.
		

Crossrefs

Programs

  • Maple
    with(numtheory); f := n->min(nextprime(n)-n, n-prevprime(n));
  • Mathematica
    Table[Min[NextPrime[n]-n,n-NextPrime[n,-1]],{n,0,200}]  (* Harvey P. Dale, Mar 27 2011 *)

Extensions

More terms from James Sellers

A046930 Size of sea of composite numbers surrounding n-th prime.

Original entry on oeis.org

1, 1, 2, 4, 4, 4, 4, 4, 8, 6, 6, 8, 4, 4, 8, 10, 6, 6, 8, 4, 6, 8, 8, 12, 10, 4, 4, 4, 4, 16, 16, 8, 6, 10, 10, 6, 10, 8, 8, 10, 6, 10, 10, 4, 4, 12, 22, 14, 4, 4, 8, 6, 10, 14, 10, 10, 6, 6, 8, 4, 10, 22, 16, 4, 4, 16, 18, 14, 10, 4, 8, 12, 12, 10, 8, 8, 12, 10, 10, 16, 10, 10, 10, 6, 8, 8
Offset: 1

Views

Author

Keywords

Examples

			23 is in a sea of 8 composites: 20,21,22,23,24,25,26,27,28.
		

Crossrefs

Programs

  • Haskell
    a046930 1 = 1
    a046930 n = subtract 2 $ a031131 n  -- Reinhard Zumkeller, Dec 19 2013
  • Maple
    [ seq(ithprime(i)-ithprime(i-2)-2,i=3..100) ];
  • Mathematica
    Table[ Prime[n + 2] - Prime[n] - 2, {n, 75}] (* Robert G. Wilson v Oct 27 2004 *)
    Join[{1},#[[3]]-#[[1]]-2&/@Partition[Prime[Range[90]],3,1]] (* Harvey P. Dale, Sep 26 2012 *)

Formula

a(n) = A031131(n) - 2 for n > 1. - Reinhard Zumkeller, Dec 19 2013

Extensions

More terms from Michel ten Voorde

A051701 Closest prime to n-th prime p that is different from p (break ties by taking the smaller prime).

Original entry on oeis.org

3, 2, 3, 5, 13, 11, 19, 17, 19, 31, 29, 41, 43, 41, 43, 47, 61, 59, 71, 73, 71, 83, 79, 83, 101, 103, 101, 109, 107, 109, 131, 127, 139, 137, 151, 149, 151, 167, 163, 167, 181, 179, 193, 191, 199, 197, 199, 227, 229, 227, 229, 241, 239, 257, 251, 257, 271, 269
Offset: 1

Views

Author

Keywords

Comments

A227878 gives the terms occurring twice. - Reinhard Zumkeller, Oct 25 2013

Examples

			Closest primes to 2,3,5,7,11 are 3,2,3,5,13.
		

Crossrefs

Programs

  • Haskell
    a051701 n = a051701_list !! (n-1)
    a051701_list = f 2 $ 1 : a000040_list where
       f d (q:ps@(p:p':_)) = (if d <= d' then q else p') : f d' ps
         where d' = p' - p
    -- Reinhard Zumkeller, Oct 25 2013
    
  • Mathematica
    a[n_] := (p = Prime[n]; np = NextPrime[p]; pp = NextPrime[p, -1]; If[np-p < p-pp, np, pp]); Table[a[n], {n, 1, 58}] (* Jean-François Alcover, Oct 20 2011 *)
    cp[{a_,b_,c_}]:=If[c-bHarvey P. Dale, Oct 08 2012 *)
  • Python
    from sympy import nextprime
    def aupton(terms):
      prv, cur, nxt, alst = 0, 2, 3, []
      while len(alst) < terms:
        alst.append(prv if 2*cur - prv <= nxt else nxt)
        prv, cur, nxt = cur, nxt, nextprime(nxt)
      return alst
    print(aupton(58)) # Michael S. Branicky, Jun 04 2021

Extensions

More terms from James Sellers

A102723 Smallest prime a(n) such that a(n)-x and a(n)+x, for x=1 to n, are all composite.

Original entry on oeis.org

5, 23, 23, 53, 53, 211, 211, 211, 211, 211, 211, 1847, 1847, 2179, 2179, 2179, 2179, 3967, 3967, 16033, 16033, 16033, 16033, 24281, 24281, 24281, 24281, 24281, 24281, 38501, 38501, 38501, 38501, 38501, 38501, 38501, 38501, 38501, 38501, 58831
Offset: 1

Views

Author

Ray G. Opao, Feb 06 2005

Keywords

Comments

a(2n+1)=a(2n). - Robert G. Wilson v, Feb 22 2005
Using Dirichlet's theorem, Sierpiński (1948) proved that a(n) exists for all n > 0. He noted that a(n) is a non-twin prime (A007510), except for a(1) = 5. - Jonathan Sondow, Oct 27 2017

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 1}, While[ Union[ PrimeQ /@ Sort[ Flatten[ Table[{Prime[k] - i, Prime[k] + i}, {i, n}]]]] != {False}, k++ ]; Prime[k]]; Table[ f[n], {n, 40}] (* Robert G. Wilson v, Feb 22 2005 *)
    cmpgap[n_]:=Module[{p=Prime[n]},Min[p-NextPrime[p,-1],NextPrime[p]-p]]; Module[{nn=10000,prs},prs=Table[{Prime[n],cmpgap[n]},{n,nn}];Table[ SelectFirst[ prs,#[[2]]>=k&],{k,2,50}]][[All,1]] (* Harvey P. Dale, Oct 15 2021 *)

Extensions

a(12)-a(40) from Robert G. Wilson v, Feb 22 2005

A330428 Smallest prime p such that both nearest primes up and down are farther away than n*log(p).

Original entry on oeis.org

5, 211, 38501, 413353, 10938023, 142414669, 163710121, 8835528511, 31587561361, 343834606051, 1480975873513, 26923643849953
Offset: 1

Views

Author

Steven M. Altschuld, Dec 14 2019

Keywords

Comments

For these numbers, the name "Lowest Frogger Primes" LFP(n) is suggested because (frog) jumps with a length greater than n times the local average are required to bridge the gaps (logs).

Crossrefs

Cf. A288908 (with 1*log(P)), A330426 (with 2*log(P)), A330427 (with 3*log(P)).

Programs

  • PARI
    {my(npp=2,np=3,n=1);forprime(p=5,10^9,my(d=log(p)*n);if(np-npp>d&&p-np>d,print(np,", ");n++);npp=np;np=p)} \\ Hugo Pfoertner, Dec 14 2019

Extensions

a(5)-a(9) from Hugo Pfoertner, Dec 14 2019
a(10) from Hugo Pfoertner, Dec 16 2019
a(11)-a(12) from Giovanni Resta, Dec 19 2019

A051698 Closest prime to n that is different from n (break ties by taking the smaller prime).

Original entry on oeis.org

2, 2, 3, 2, 3, 3, 5, 5, 7, 7, 11, 13, 11, 11, 13, 13, 17, 19, 17, 17, 19, 19, 23, 19, 23, 23, 23, 29, 29, 31, 29, 29, 31, 31, 31, 37, 37, 41, 37, 37, 41, 43, 41, 41, 43, 43, 47, 43, 47, 47, 47, 53, 53, 47, 53, 53, 53, 59, 59, 61, 59, 59, 61, 61, 61, 67, 67, 71, 67, 67, 71, 73
Offset: 0

Views

Author

Keywords

Examples

			Closest primes to 0,1,2,3,4 are 2,2,3,2,3.
		

Crossrefs

Programs

  • Mathematica
    cp[n_]:=Module[{p1=NextPrime[n,-1],p2=NextPrime[n]},If[p2-nHarvey P. Dale, Dec 11 2018 *)

Extensions

More terms from James Sellers

A051729 Smallest number at distance 2n+1 from nearest prime.

Original entry on oeis.org

1, 26, 118, 120, 532, 1140, 1340, 1342, 1344, 15702, 15704, 19632, 19634, 31424, 31426, 31428, 31430, 31432, 155958, 155960, 155962, 155964, 360698, 360700, 370310, 370312, 370314, 370316, 492170, 1349592, 1357262, 1357264, 1357266, 2010800, 2010802, 2010804, 2010806
Offset: 0

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    seq[max_] := Module[{s = Table[0, {max}], c = 1, n = 4}, s[[1]] = 1; While[c < max, i = (Min[n - NextPrime[n, -1], NextPrime[n] - n] + 1)/2; If[i <= max && s[[i]] == 0, c++; s[[i]] = n]; n += 2]; s] ; seq[20] (* Amiram Eldar, Aug 28 2021 *)
    With[{tbl=Table[{n,If[PrimeQ[n],2,Min[n-NextPrime[n,-1],NextPrime[n]-n]]},{n,500000}]},Table[SelectFirst[tbl,#[[2]]==2k+1&],{k,0,28}]][[;;,1]] (* The program generates the first 29 terms of the sequence. *) (* Harvey P. Dale, Jul 06 2025 *)

Formula

a(n) = A051652(2*n+1). - Sean A. Irvine, Oct 01 2021

Extensions

More terms from James Sellers, Dec 07 1999
More terms from Amiram Eldar, Aug 28 2021

A087770 "Lonely primes": those primes that are locally maximally isolated from the nearest other primes. The differences between each lonely prime and the immediately preceding prime and following primes are both greater than the corresponding differences for all lonely primes earlier in the sequence.

Original entry on oeis.org

2, 3, 7, 23, 89, 211, 1847, 2179, 14107, 33247, 38501, 58831, 268343, 1272749, 2198981, 10938023, 72546283, 162821917, 325737821, 2888688863, 6613941601, 11179888193, 24016237123, 96155166493, 179474021633, 215686840471, 633880576177, 1480975873513, 9156364643509
Offset: 1

Views

Author

Walter Carlini, Oct 03 2003

Keywords

Comments

The concept of "lonely prime" is similar to that of maximal prime gaps since lonely primes are increasingly distant from each other.
See A023186 for another version of this sequence, which only requires increasing the minimum of the two gaps to the neighbors. The definition from A023186 seems to be the more common variant. - Hugo Pfoertner, Dec 17 2019

Examples

			a(0) = 2.
a(1) = 3 because 3 - 2 = 1 and 5 - 3 = 2.
a(2) = 7 because 7 - 5 = 2 (and 2 > 3 - 2) and 11 - 7 = 4 (and 4 > 5 - 3).
a(3) = 23 because 23 - 19 = 4 ( 23 - 19 > 7 - 5) and 29 - 23 = 6 (29 - 23 > 11 - 7).
a(4) = 89 because 89 - 83 = 6 > 23 - 19 and 97 - 89 = 8 > 29 - 23.
Note, for example, that 53 is not a lonely prime because 53 - 47 = 6, which is > 23 - 19 however 59 - 53 = 6, which is not > 29 - 23.
		

Crossrefs

Programs

  • Mathematica
    NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; p = 2; q = 2; r = 3; d = e = 0; Do[ While[ q - p <= d || r - q <= e, p = q; q = r; r = NextPrim[r]]; Print[q]; d = Max[q - p, d]; e = Max[r - q, e]; p = q; q = r; r = NextPrim[r], {n, 1, 40}] (* Robert G. Wilson v *)

Extensions

Corrected and extended by Ray Chandler, Oct 06 2003
Offset changed and a(21)-a(27) from Hugo Pfoertner, Dec 17 2019
a(28)-a(29) from Giovanni Resta, Dec 17 2019

A120937 Least prime such that the distance to the two adjacent primes is 2n or greater.

Original entry on oeis.org

3, 5, 23, 53, 211, 211, 211, 1847, 2179, 2179, 3967, 16033, 16033, 24281, 24281, 24281, 38501, 38501, 38501, 38501, 38501, 58831, 203713, 206699, 206699, 413353, 413353, 413353, 1272749, 1272749, 1272749, 1272749, 2198981, 2198981, 2198981
Offset: 0

Views

Author

T. D. Noe, Jul 21 2006

Keywords

Comments

Erdos and Suranyi call these reclusive primes and prove that such a prime exists for all n. Except for a(0), the record values are in A023186.

Examples

			a(3)=53 because the adjacent primes 47 and 59 are at distance 6 and all smaller primes have a closer distance.
		

References

  • Paul Erdős and Janos Suranyi, Topics in the theory of numbers, Springer, 2003.

Crossrefs

Programs

  • Mathematica
    k=2; Table[While[Prime[k]-Prime[k-1]<2n || Prime[k+1]-Prime[k]<2n, k++ ]; Prime[k], {n,0,40}]

A023187 Distances of increasingly lonely primes to nearest prime.

Original entry on oeis.org

1, 2, 4, 6, 12, 14, 18, 20, 24, 30, 40, 42, 44, 48, 54, 62, 72, 76, 96, 98, 108, 116, 124, 136, 156, 160, 162, 168, 174, 176, 178, 180, 186, 194, 210, 214, 222, 242, 244, 246, 250, 258, 268, 284, 300, 324, 328, 340, 348, 352, 390, 396, 420, 432, 452, 480
Offset: 1

Views

Author

Keywords

Comments

These are the distances mentioned in A023186.

Examples

			The nearest prime to 23 is 4 units away, larger than any previous prime, so 4 is in the sequence.
		

Crossrefs

Programs

  • Mathematica
    t={}; max=p=0; q=2; Do[r=NextPrime[q]; If[(min=Min[q-p,r-q])>max, max=min; AppendTo[t,max]]; p=q; q=r, {n,828000}]; t (* Jayanta Basu, May 18 2013 *)

Extensions

More terms from Jud McCranie, Jun 16 2000
More terms from T. D. Noe, Jul 21 2006
More terms from Dmitry Petukhov, Oct 03 2015
Previous Showing 11-20 of 24 results. Next