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 20 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

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

A132470 Smallest number at distance exactly 3n from nearest prime.

Original entry on oeis.org

2, 26, 119, 532, 1339, 1342, 9569, 15704, 19633, 31424, 31427, 31430, 31433, 155960, 155963, 360698, 360701, 370312, 370315, 492170, 1357261, 1357264, 1357267, 2010802, 2010805, 4652428, 17051785, 17051788, 17051791, 17051794, 17051797, 20831416, 20831419, 20831422
Offset: 0

Views

Author

Jonathan Vos Post, Sep 03 2007

Keywords

Comments

Let f(m)= A051699(m) = exact distance from m to its closest prime (including m itself). Then a(n) = min { m : f(m) = 3n}. - R. J. Mathar, Nov 18 2007
This sequence can be derived from the record prime gap sequences A002386 and A005250. In particular, for n > 0, a(n) = A002386(k) + 3*n where k is the least index such that A005250(k) >= 3*n. - Andrew Howroyd, Jan 04 2020

Examples

			a(3)=532 where 532+3*3 is prime and all numbers below 532 have a distance smaller or larger than 3n=9 to their nearest primes and there is no prime within a distance of 8 to 532.
		

Crossrefs

Programs

  • Maple
    A051699 := proc(m) if isprime(m) then 0 ; elif m <= 2 then op(m+1,[2,1]) ; else min(nextprime(m)-m,m-prevprime(m)) ; fi ; end: A132470 := proc(n) local m ; if n = 0 then RETURN(2); else for m from 0 do if A051699(m) = 3 * n then RETURN(m) ; fi ; od: fi ; end: seq(A132470(n),n=0..18) ; # R. J. Mathar, Nov 18 2007
  • Mathematica
    terms = 34;
    gaps = Cases[Import["https://oeis.org/A002386/b002386.txt", "Table"], {, }][[;; terms, 2]];
    w[n_] := (NextPrime[gaps[[n]] + 1] - gaps[[n]])/6 // Floor;
    k = 1; a[0] = 2;
    For[n = 1, n <= terms, n++, While[w[k] < n, k++]; a[n] = gaps[[k]] + 3n];
    a /@ Range[0, terms-1] (* Jean-François Alcover, Apr 09 2020, after Andrew Howroyd *)
  • PARI
    \\ here R(gaps) wants prefix of A002386 as vector.
    aA002386(lim)={my(L=List(),q=2,g=0); forprime(p=3, lim, if(p-q>g, listput(L,q); g=p-q); q=p); Vec(L)}
    R(gaps)={my(w=vector(#gaps, n, nextprime(gaps[n]+1) - gaps[n])\6, r=vector(w[#w]+1), k=1); r[1]=2; for(n=1, w[#w], while(w[k]A002386(10^7))} \\ Andrew Howroyd, Jan 04 2020

Formula

a(n) = min {m : A051699(m) = 3n}. - R. J. Mathar, Nov 18 2007

Extensions

Corrected by Dean Hickerson, Sep 05 2007
Both this sequence and A051728 should be checked. There are two possibilities for confusion in each case. In defining f(m), does one allow or exclude m itself, in case m is a prime? In defining a(n), does one require (here) that f(m) = 3n or only that >= 3n, or (in A051728) that f(m) = 2n or only >= 2n? Probably there should be several sequences, to include all the possibilities in each case. - N. J. A. Sloane, Nov 18 2007. Added Nov 20 2007: R. J. Mathar has now clarified the definition of the present sequence.
Corrected and extended by R. J. Mathar, Nov 18 2007
Terms a(19) and beyond from Andrew Howroyd, Jan 04 2020

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

A062816 a(n) = phi(n)*tau(n) - 2n = A000010(n)*A000005(n) - 2*n.

Original entry on oeis.org

-1, -2, -2, -2, -2, -4, -2, 0, 0, -4, -2, 0, -2, -4, 2, 8, -2, 0, -2, 8, 6, -4, -2, 16, 10, -4, 18, 16, -2, 4, -2, 32, 14, -4, 26, 36, -2, -4, 18, 48, -2, 12, -2, 32, 54, -4, -2, 64, 28, 20, 26, 40, -2, 36, 50, 80, 30, -4, -2, 72, -2, -4, 90, 96, 62, 28, -2, 56, 38, 52, -2, 144, -2, -4, 90, 64, 86, 36, -2, 160, 108, -4, -2, 120, 86, -4
Offset: 1

Views

Author

Labos Elemer, Jul 20 2001

Keywords

Comments

It can be shown that phi(n)*tau(n) >= n, which means that quotient = n/tau(n) <= phi(n); note: a(n)+5 is positive.
The value is always positive except when a(n) = 0 for {8,9,12}; or a(n) = -2 for primes together with 4 (i.e., for A046022 but without 1); or a(n) = -4 for A001747 (without 2 and 4); or a(n) = -1 for n = 1.

Crossrefs

Programs

  • Mathematica
    Table[EulerPhi[n]DivisorSigma[0,n]-2n,{n,90}] (* Harvey P. Dale, Feb 03 2021 *)
  • PARI
    a(n)={eulerphi(n)*numdiv(n) - 2*n} \\ Harry J. Smith, Aug 11 2009

Formula

a(n) = A062355(n) - 2*n. - Amiram Eldar, Jul 10 2024

Extensions

Offset changed from 0 to 1 by Harry J. Smith, Aug 11 2009

A132860 Smallest number at distance 2n from nearest prime (variant 2).

Original entry on oeis.org

2, 0, 93, 119, 531, 897, 1339, 1341, 1343, 9569, 15703, 15705, 19633, 19635, 31425, 31427, 31429, 31431, 31433, 155959, 155961, 155963, 360697, 360699, 360701, 370311, 370313, 370315, 370317, 1349591, 1357261, 1357263, 1357265, 1357267
Offset: 1

Views

Author

R. J. Mathar, Nov 18 2007, Nov 30 2007

Keywords

Comments

Let f(m) be the distance to the nearest prime as defined in A051699(m). Then a(n) = min { m: f(m)= 2n }. A051728 uses A051700(m) to define the distance.
Note that the requirement f(m)>=2n yields the same sequence as f(m)=2n here. (Reasoning: We are essentially probing for prime gaps of size 4n or larger while increasing m. One cannot get earlier hits by relaxing the requirement from the equal to the larger-or-equal sign, because m triggers as soon as the distance to the start of the gap reaches 2n, with both definitions. This is an inherent consequence of using A051699.)

Crossrefs

Programs

  • Maple
    A051699 := proc(m) if isprime(m) then 0 ; elif m <= 2 then op(m+1,[2,1]) ; else min(nextprime(m)-m,m-prevprime(m)) ; fi ; end: a := proc(n) local m ; for m from 0 do if A051699(m) = 2 * n then RETURN(m) ; fi ; od: end: seq(a(n),n=0..18);

Formula

a(n) = min {m : A051699(m) = 2n}.

A133490 Smallest number at distance 2n from nearest prime (variant 3).

Original entry on oeis.org

2, 0, 23, 53, 211, 211, 211, 1341, 1343, 2179, 3967, 15705, 16033, 19635, 24281, 24281, 31429, 31431, 31433, 38501, 38501, 58831, 203713, 206699, 206699, 370311, 370313, 370315, 370317, 1272749, 1272749, 1272749, 1357265, 1357267, 2010801
Offset: 0

Views

Author

R. J. Mathar, Nov 30 2007

Keywords

Comments

Let f(m) be the distance to the nearest prime as defined in A051700(m). Then a(n) = min { m: f(m)>= 2n}. The variants of a different definition of "distance" or demanding equality, f(m)=2n, are in A132860 and A051728.
Previous Showing 11-20 of 20 results.