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.

A051730 Distance from A051650(n) to nearest prime.

Original entry on oeis.org

2, 4, 6, 7, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25, 26, 30, 31, 32, 33, 34, 35, 36, 40, 42, 43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 96, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109
Offset: 0

Views

Author

Keywords

Examples

			23 is 4 units away from the closest prime (not including itself), so 4 is in the sequence.
		

Crossrefs

Programs

  • Mathematica
    (* b stands for A051650 *) d[0] = 2; d[k_] := Min[k - NextPrime[k, -1], NextPrime[k] - k]; b[0] = 0; b[n_] := b[n] = (k = b[n-1] + 1; record = d[b[n-1]]; While[d[k] <= record, k++]; k); a[n_] := a[n] = d[b[n]]; Table[ Print[ a[n]]; a[n], {n, 0, 66}] (* Jean-François Alcover, Jan 16 2012 *)
  • PARI
    print1(w=2);p=2;q=3;forprime(r=5,1e9,if(p+w+ww,w=t;print1(", "t));p=q;q=r) \\ Charles R Greathouse IV, Jan 16 2012
  • UBASIC
    [10] C#=pack(3,5):R=2:N=4:print 2; [20] if N>member(C#,2) then C#=pack(member( C#,2)):C#=C#+nxtprm(member(C#,1)) [30] Prv=member(C#,1):Nxt=member(C#,2) [40] if Nxt=N then Nxt=nxtprm(N) [50] if (N-Prv)>=(Nxt-N) then P=Nxt-N else P=N-Prv [60] if P>R then print P;:R=P [70] N+=1 :goto 20
    

Extensions

More terms from James Sellers, Dec 23 1999 and from Jud McCranie, Jun 16 2000
Further terms from Naohiro Nomoto, Jun 21 2001

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

A261525 a(n) = smallest m such that A031131(m) = 2*n.

Original entry on oeis.org

2, 3, 9, 8, 15, 23, 47, 29, 66, 114, 46, 220, 188, 258, 640, 375, 480, 589, 216, 326, 367, 1006, 738, 1183, 1985, 1847, 1662, 2224, 3731, 3861, 3561, 2699, 3792, 4521, 2225, 12541, 3384, 12761, 3385, 4058, 10228, 15747, 15927, 14357, 18280, 19025, 14123
Offset: 2

Views

Author

Reinhard Zumkeller, Aug 23 2015

Keywords

Comments

A031131(a(n)) = 2*n and A031131(m) != 2*n for m < a(n);
A046931(n) = A000040(a(n)+1);
a(n)-th and (a(n)+2)-nd primes are the first pair that differ by 2*n;
conjecture: sequence is defined for all n > 1.

Crossrefs

Programs

  • Haskell
    a261525 = (+ 1) . fromJust . (`elemIndex` a031131_list) . (* 2)

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

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

A098968 Record values for size of sea of composite numbers surrounding primes.

Original entry on oeis.org

0, 1, 2, 4, 8, 10, 12, 16, 22, 26, 38, 40, 42, 46, 48, 54, 56, 70, 74, 78, 80, 98, 112, 114, 124, 136, 138, 158, 188, 198, 232, 234, 244, 246, 268, 304, 326, 328, 334, 338, 370
Offset: 0

Views

Author

N. J. A. Sloane, Oct 24 2004

Keywords

Comments

For a prime p let s(p) (essentially A046930) denote the number of composite numbers less than p and greater than max{1, previous prime} or greater than p and less than the next prime. Sequence gives record values of s(p).

Crossrefs

Records in A046930 (if initial term is 0 not 1). Cf. A098969, A046931.

Programs

  • Mathematica
    a = {1, 2}; b = {0, 1}; d = 1; p = 2; q = 3; Do[ r = Prime[n]; c = r - p - 2; If[c > d, Print[{n + 1, c}]; d = c; AppendTo[a, n - 1]; AppendTo[b, c]]; p = q; q = r, {n, 3, 10^9}]; b (* Robert G. Wilson v, Oct 27 2004 *)
    Join[{0},DeleteDuplicates[Total/@Partition[Differences[Prime[Range[5*10^6]]]-1,2,1],GreaterEqual]] (* The program generates the first 34 terms of the sequence. *) (* Harvey P. Dale, May 25 2025 *)

Extensions

More terms from Robert G. Wilson v and Olaf Voß, Oct 27 2004

A377971 Square array of primes p >= 7, read by decreasing antidiagonals. Each row lists, in increasing order, the primes that share the same sum of their neighboring prime gaps.

Original entry on oeis.org

7, 11, 29, 13, 31, 23, 17, 59, 37, 53, 19, 61, 47, 97, 89, 41, 73, 67, 139, 199, 223, 43, 137, 79, 149, 359, 251, 113, 71, 151, 83, 157, 367, 337, 127, 331, 101, 179, 131, 173, 389, 467, 307, 479, 631, 103, 239, 163, 181, 449, 547, 317, 523, 797, 211, 107, 269, 167, 191, 521, 557, 409, 953, 1087, 293, 1381
Offset: 1

Views

Author

Tamas Sandor Nagy, Nov 13 2024

Keywords

Comments

First column is subset of A046931, which starts with 3. Here, 3 and 5 are omitted.
The related sum can be denoted Sum_prime_gaps, S = pg_inf + pg_sup.

Examples

			Square array begins:
.
S = pg_inf + pg_sup |
      2*(3..k)      |
-----------------------------------------------------------------------
          6         |   7,  11,  13,  17,  19,  41,  43,  71, 101, ... A098414
          8         |  29,  31,  59,  61,  73, 137, 151, 179, 239, ...
         10         |  23,  37,  47,  67,  79,  83, 131, 163, 167, ...
         12         |  53,  97, 139, 149, 157, 173, 181, 191, 241, ...
         14         |  89, 199, 359, 367, 389, 449, 521, 619, 661, ...
.
31, 59 and 179 are in the same row because their preceding and succeeding prime gaps, (pg_inf, pg_sup), respectively (2,6), (6,2) and (6,2) each equally sum up to 8.
53 and 181 are in the same row because their preceding and succeeding prime gaps, (pg_inf, pg_sup), respectively (6,6) and (2,10) each equally sum up to 12. Here, 53 also happens to be a balanced prime as its corresponding gaps, (6,6), are equal.
		

Crossrefs

Formula

Sum_prime_gaps_a(n) = S_a(n) = (A002260(n))*2 + 4.
Previous Showing 11-20 of 20 results.