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-18 of 18 results.

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

A060268 Distance of 2n from the closest prime.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 7, 5, 3, 1, 1, 1, 1, 3, 1, 1, 1, 3, 5, 3, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 3, 5, 3, 1, 1, 1, 1, 1, 1, 3, 5, 5, 3, 1, 1
Offset: 2

Views

Author

Labos Elemer, Mar 23 2001

Keywords

Examples

			n=13, 2n=26 surrounded by 23 and 29 which are from 26 in equal distance of 3 and min{3,3}=3=a(13).
		

Crossrefs

Programs

  • Maple
    with(numtheory): [seq(min(nextprime(2*i)-2*i, 2*i-prevprime(2*i)), i=2...256)];
  • Mathematica
    a[n_] := Min[NextPrime[2*n] - 2*n, 2*n - NextPrime[2*n, -1]]; Array[a, 100, 2] (* Amiram Eldar, Sep 16 2020 *)
  • PARI
    a(n) = min(2*n - precprime(2*n-1), nextprime(2*n+1) - 2*n); \\ Michel Marcus, Sep 16 2020

Formula

a(n) = min(A049653(n), A060266(n)). - Michel Marcus, Sep 16 2020

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

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

A137872 Prime numbers, isolated from neighboring primes by >10.

Original entry on oeis.org

211, 1511, 1847, 2179, 2503, 2579, 2633, 2819, 2939, 3137, 3271, 3433, 3659, 3967, 3989, 4111, 4177, 4409, 4621, 4691, 4703, 4831, 4889, 5039, 5209, 5261, 5623, 5939, 5953, 6619, 6637, 6883, 7057, 7283, 7369, 7393, 7433, 7621, 7741, 7841, 7853, 7963
Offset: 1

Views

Author

Keywords

Comments

Prime numbers prime(n) such that A051702(n) exceeds 10. - Stefan Steinerberger, May 02 2008

Programs

  • Mathematica
    q=10;s="";For[i=1,i<12^2,p=Prime[i];a=0;For[j=2,j<=q,If[PrimeQ[p-j]||PrimeQ[p+j], a=1;Break[]];j=j+2];If[a==0,s=s<>ToString[p]<>","];i++ ];Print[s]
    Prime[Select[Range[2, 1500], Prime[ # - 1] + 10 < Prime[ # ] < Prime[ # + 1] - 10 &]] (* Stefan Steinerberger, May 02 2008 *)

Extensions

Edited and extended by Stefan Steinerberger, May 02 2008
Description edited by Ray Chandler, May 02 2009

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-18 of 18 results.