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.

Showing 1-10 of 14 results. Next

A082467 Least k>0 such that n-k and n+k are both primes.

Original entry on oeis.org

1, 2, 1, 4, 3, 2, 3, 6, 1, 6, 3, 2, 3, 6, 1, 12, 3, 2, 9, 6, 5, 6, 3, 4, 9, 12, 1, 12, 9, 4, 3, 6, 5, 6, 9, 2, 3, 12, 1, 24, 3, 2, 15, 6, 5, 12, 3, 8, 9, 6, 7, 12, 3, 4, 15, 12, 1, 18, 9, 4, 3, 6, 5, 6, 15, 2, 3, 12, 1, 6, 15, 4, 3, 6, 5, 18, 9, 2, 15, 24, 5, 12, 3, 14, 9, 18, 7, 12, 9, 4, 15, 6, 7, 30, 9
Offset: 4

Views

Author

Benoit Cloitre, Apr 27 2003

Keywords

Comments

The existence of k>0 for all n >= 4 is equivalent to the strong Goldbach Conjecture that every even number >= 8 is the sum of two distinct primes.
n and k are coprime, because otherwise n + k would be composite. So the rational sequence r(n) = a(n)/n = k/n is injective. - Jason Kimberley, Sep 21 2011
Because there are arbitrarily many composites from m!+2 to m!+m, there are also arbitrarily large a(n) but they increase very slowly. The twin prime conjecture implies that infinitely many a(n) are 1. - Juhani Heino, Apr 09 2020

Examples

			n=10: k=3 because 10-3 and 10+3 are both prime and 3 is the smallest k such that n +/- k are both prime.
		

Crossrefs

Cf. A129301 (records), A129302 (where records occur).
Cf. A047160 (allows k=0).
Cf. A078611 (subset for prime n).

Programs

  • Magma
    A082467 := func; [A082467(n):n in [4..98]]; // Jason Kimberley, Sep 03 2011
  • Maple
    A082467 := proc(n) local k; k := 1+irem(n,2);
    while n > k do if isprime(n-k) then if isprime(n+k)
    then RETURN(k) fi fi; k := k+2 od; print("Goldbach erred!") end:
    seq(A082467(i),i=4..90); # Peter Luschny, Sep 21 2011
  • Mathematica
    f[n_] := Block[{k}, If[OddQ[n], k = 2, k = 1]; While[ !PrimeQ[n - k] || !PrimeQ[n + k], k += 2]; k]; Table[ f[n], {n, 4, 98}] (* Robert G. Wilson v, Mar 28 2005 *)
  • PARI
    a(n)=if(n<0,0,k=1; while(isprime(n-k)*isprime(n+k) == 0,k++); k)
    

Formula

A078496(n)-a(n) = A078587(n)+a(n) = n.

Extensions

Entries checked by Klaus Brockhaus, Apr 08 2007

A047160 For n >= 2, a(n) = smallest number m >= 0 such that n-m and n+m are both primes, or -1 if no such m exists.

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 3, 2, 3, 0, 1, 0, 3, 2, 3, 0, 1, 0, 3, 2, 9, 0, 5, 6, 3, 4, 9, 0, 1, 0, 9, 4, 3, 6, 5, 0, 9, 2, 3, 0, 1, 0, 3, 2, 15, 0, 5, 12, 3, 8, 9, 0, 7, 12, 3, 4, 15, 0, 1, 0, 9, 4, 3, 6, 5, 0, 15, 2, 3, 0, 1, 0, 15, 4, 3, 6, 5, 0, 9, 2, 15, 0, 5, 12, 3, 14, 9, 0, 7, 12, 9, 4, 15, 6, 7, 0, 9, 2, 3
Offset: 2

Views

Author

Keywords

Comments

I have confirmed there are no -1 entries through integers to 4.29*10^9 using PARI. - Bill McEachen, Jul 07 2008
From Daniel Forgues, Jul 02 2009: (Start)
Goldbach's Conjecture: for all n >= 2, there are primes (distinct or not) p and q s.t. p+q = 2n. The primes p and q must be equidistant (distance m >= 0) from n: p = n-m and q = n+m, hence p+q = (n-m)+(n+m) = 2n.
Equivalent to Goldbach's Conjecture: for all n >= 2, there are primes p and q equidistant (distance >= 0) from n, where p and q are n when n is prime.
If this conjecture is true, then a(n) will never be set to -1.
Twin Primes Conjecture: there is an infinity of twin primes.
If this conjecture is true, then a(n) will be 1 infinitely often (for which each twin primes pair is (n-1, n+1)).
Since there is an infinity of primes, a(n) = 0 infinitely often (for which n is prime).
(End)
If n is composite, then n and a(n) are coprime, because otherwise n + a(n) would be composite. - Jason Kimberley, Sep 03 2011
From Jianglin Luo, Sep 22 2023: (Start)
a(n) < primepi(n)+sigma(n,0);
a(n) < primepi(primepi(n)+n);
a(n) < primepi(n), for n>344;
a(n) = o(primepi(n)), as n->+oo. (End)
If -1 < a(n) < n-3, then a(n) is divisible by 3 if and only if n is not divisible by 3, and odd if and only if n is even. - Robert Israel, Oct 05 2023

Examples

			16-3=13 and 16+3=19 are primes, so a(16)=3.
		

Crossrefs

Programs

  • Haskell
    a047160 n = if null ms then -1 else head ms
                where ms = [m | m <- [0 .. n - 1],
                                a010051' (n - m) == 1, a010051' (n + m) == 1]
    -- Reinhard Zumkeller, Aug 10 2014
    
  • Magma
    A047160:=func;[A047160(n):n in[2..100]]; // Jason Kimberley, Sep 02 2011
    
  • Mathematica
    Table[k = 0; While[k < n && (! PrimeQ[n - k] || ! PrimeQ[n + k]), k++]; If[k == n, -1, k], {n, 2, 100}]
    smm[n_]:=Module[{m=0},While[AnyTrue[n+{m,-m},CompositeQ],m++];m]; Array[smm,100,2] (* Harvey P. Dale, Nov 16 2024 *)
  • PARI
    a(n)=forprime(p=n,2*n, if(isprime(2*n-p), return(p-n))); -1 \\ Charles R Greathouse IV, Jun 23 2017
  • UBASIC
    10 N=2// 20 M=0// 30 if and{prmdiv(N-M)=N-M,prmdiv(N+M)=N+M} then print M;:goto 50// 40 inc M:goto 30// 50 inc N: if N>130 then stop// 60 goto 20
    

Formula

a(n) = n - A112823(n).
a(n) = A082467(n) * A005171(n), for n > 3. - Jason Kimberley, Jun 25 2012

Extensions

More terms from Patrick De Geest, May 15 1999
Deleted a comment. - T. D. Noe, Jan 22 2009
Comment corrected and definition edited by Daniel Forgues, Jul 08 2009

A078497 The member r of a triple of primes (p,q,r) in arithmetic progression which sum to 3*prime(n) = A001748(n) = p + q + r.

Original entry on oeis.org

7, 11, 17, 19, 23, 31, 29, 41, 43, 43, 53, 67, 53, 59, 71, 79, 73, 83, 79, 97, 107, 107, 127, 113, 109, 113, 139, 137, 151, 149, 167, 151, 167, 163, 163, 199, 197, 179, 191, 199, 233, 223, 227, 241, 223, 283, 257, 277, 239, 251, 271, 263, 263, 269, 281, 313
Offset: 3

Views

Author

Serhat Sevki Dincer (sevki(AT)ug.bilkent.edu.tr), Nov 27 2002

Keywords

Comments

In case more than one triple of primes p, q=p+d and r=p+2*d exists, we take r=a(n) from the triple with the smallest d. This shows the difference from A092940, which would take the maximum r over all triples. - R. J. Mathar, May 19 2007

Examples

			a(1) = 7 because 3+5+7 = 15;
a(2) = 11 because 3+7+11 = 21;
a(3) = 17 because 5+11+17= 33.
		

Crossrefs

Programs

  • Maple
    A078497 := proc(n) local p3, i,d,r,p; p3 := ithprime(n) ; i := n+1 ; while true do r := ithprime(i) ; d := r-p3 ; p := p3-d ; if isprime(p) then RETURN(r) ; fi ; i := i+1 ; od ; RETURN(-1) ; end: for n from 3 to 60 do printf("%d, ",A078497(n)) ; od ; # R. J. Mathar, May 19 2007
  • Mathematica
    f[n_] := Block[{p = Prime[n], k}, k = p + 1; While[ !PrimeQ[k] || !PrimeQ[2p - k], k++ ]; k]; Table[ f[n], {n, 3, 60}]

Extensions

Edited and extended by Robert G. Wilson v, Nov 29 2002
Further edited by N. J. A. Sloane, Jul 03 2008 at the suggestion of R. J. Mathar

A094709 Smallest k such that prime(n)# - k and prime(n)# + k are primes, where prime(n)# = A002110(n).

Original entry on oeis.org

0, 1, 1, 13, 1, 17, 59, 23, 79, 101, 83, 239, 71, 149, 367, 73, 911, 313, 373, 523, 313, 331, 197, 101, 1493, 523, 293, 577, 2699, 1481, 1453, 5647, 647, 419, 757, 4253, 509, 239, 10499, 191, 4013, 2659, 617, 6733, 1297, 971
Offset: 1

Views

Author

Reinhard Zumkeller, May 21 2004

Keywords

Comments

a(n) = A002110(n) - A094710(n) = A094711(n) - A002110(n),
Goldbach's conjecture implies that a(n) is defined for all n. - David Wasserman, May 31 2007

Examples

			a(4)=13 because prime(4)=7, 7# = 2*3*5*7 = 210, and 210 - 13 and 210 + 13 are primes.
		

Crossrefs

Programs

  • Mathematica
    pc[n_]:=Module[{x=0,i=0},Do[If[PrimeQ[n-i]&&PrimeQ[n+i],x=i;Break[]],{i,9!}];x]; r=2;lst={};Do[p=Prime[n];r*=p;AppendTo[lst,pc[r]],{n,2,2*4!}];lst (* Vladimir Joseph Stephan Orlovsky, Jun 14 2009 *)
    sk[n_]:=Module[{k=0},While[!PrimeQ[n+k]||!PrimeQ[n-k],k++];k]; sk/@ FoldList[ Times,Prime[Range[50]]] (* Harvey P. Dale, Apr 03 2022 *)
  • Python
    from sympy import isprime, prime, primerange
    def aupton(terms):
      phash, alst = 2, [0]
      for p in primerange(3, prime(terms)+1):
        phash *= p
        for k in range(1, phash//2):
          if isprime(phash-k) and isprime(phash+k): alst.append(k); break
      return alst
    print(aupton(46)) # Michael S. Branicky, May 29 2021

Extensions

More terms from Don Reble, May 27 2004

A127329 Semiprimes equal to the sum of three primes in arithmetic progression.

Original entry on oeis.org

15, 21, 33, 39, 51, 57, 69, 87, 93, 111, 123, 129, 141, 159, 177, 183, 201, 213, 219, 237, 249, 267, 291, 303, 309, 321, 327, 339, 381, 393, 411, 417, 447, 453, 471, 489, 501, 519, 537, 543, 573, 579, 591, 597, 633, 669, 681, 687, 699, 717, 723, 753, 771, 789
Offset: 1

Views

Author

Giovanni Teofilatto, Mar 30 2007

Keywords

Examples

			a(1) = 15 because 15 = 3 + 5 + 7;
a(2) = 21 because 21 = 3 + 7 + 11.
		

Crossrefs

Programs

  • Magma
    [3*NthPrime(n+2): n in [1..60]]; // Vincenzo Librandi, Jun 28 2015, assuming the conjecture holds

Formula

Conjecture: a(n) = 3*A000040(n+2). - Zak Seidov, Jun 28 2015
Every member of the sequence is 3 times a prime; it is believed that every prime >= 5 arises in this way. This is related to Goldbach's conjecture: see comments to A078611. - Robert Israel and Michel Marcus, Jun 28 2015

Extensions

Corrected (57 = 7+19+31, 87 = 5+29+53, etc. inserted) by R. J. Mathar, Apr 22 2010

A209266 a(n) is the number of 3-prime arithmetic progression prime chains surrounding the n-th prime number with 5-smooth intervals.

Original entry on oeis.org

0, 0, 1, 1, 2, 2, 2, 1, 3, 3, 1, 3, 3, 4, 3, 5, 4, 2, 5, 4, 4, 4, 4, 3, 3, 6, 6, 4, 4, 3, 4, 5, 6, 3, 6, 5, 4, 5, 5, 6, 4, 3, 4, 5, 5, 2, 5, 4, 6, 4, 6, 6, 3, 7, 5, 7, 6, 4, 7, 6, 5, 5, 7, 5, 4, 5, 8, 6, 7, 6, 8, 6, 7, 9, 4, 6, 5, 5, 8, 3, 6, 6, 5, 4, 6, 5, 7, 7, 8
Offset: 1

Views

Author

Lei Zhou, Feb 07 2013

Keywords

Comments

Based on the conjecture in A211376, a(n) > 0.
Last appearance of positive integers in a(n) at n<220000
a(11)=1 (a(n) > 1 for 11
a(46)=2; a(10680)=3; a(32293)=4; a(212493)=5

Examples

			n=3: prime(3)=5, 3,5,7 form a 3-prime arithmetic progression prime chain with the interval of 2, a 5-smooth number.  And this is the only case.  So a(3)=1;
...
n=43: prime(43)=191, the following 3-prime arithmetic progression prime chains exists:
  149,191,233 (gap 42=2*3*7, not 5-smooth)
  131,191,251 (gap 60=2^2*3*5, 5-smooth)
  113,191,269 (gap 78=2*3*13, not 5-smooth)
  101,191,281 (gap 90=2*3^2*5, 5-smooth)
  89,191,293  (gap 102=2*3*17, not 5-smooth)
  71,191,311  (gap 120=2^3*3*5, 5-smooth)
  29,191,353  (gap 162=2*3^4, 5-smooth)
  23,191,359  (gap 168=2^3*3*7, not 5-smooth)
  3,191,379   (gap 188=2^2*47, not 5-smooth)
Among these groups, there are 4 5-smooth gaps.  So, a(43)=4.
		

Crossrefs

Programs

  • Mathematica
    Table[p = Prime[i]; ct = 0; Do[If[(PrimeQ[p - j]) && (PrimeQ[p + j]),
       f = Last[FactorInteger[j]][[1]]; If[f <= 5, ct++]], {j, 2, p,
       2}]; ct, {i, 3, 89}]

A211376 a(n) is the smallest 5-smooth number k such that both prime(n) - k and prime(n) + k are prime.

Original entry on oeis.org

2, 4, 6, 6, 6, 12, 6, 12, 12, 6, 12, 24, 6, 6, 12, 18, 6, 12, 6, 18, 24, 18, 30, 12, 6, 6, 30, 24, 24, 18, 30, 12, 18, 12, 6, 36, 30, 6, 12, 18, 60, 30, 30, 72, 12, 60, 30, 48, 6, 12, 30, 12, 6, 6, 12, 60, 6, 12, 54, 24, 24, 48, 36, 36, 18, 30, 36, 18, 6, 90
Offset: 3

Author

Lei Zhou, Feb 07 2013

Keywords

Comments

The three numbers prime(n) - k, prime(n), prime(n) + k are an arithmetic progression of primes.
Conjecture: a(n) is defined for all integers n > 2.
Conjecture confirmed true up to n = 300000, no exceptions.
Note that if (p1, n, p2) is an arithmetic progression where p1 and p2 are prime, then 2n = p1 + p2 is a Goldbach pair. There are numbers n such that no such sequence (p1, n, p2) exists for which the common difference n - p1 = p2 - n is 5-smooth. The first such number is 90. The first such odd number is 1845.
a(n) is defined for 3 <= n <= 10^7. - David A. Corneth, Jul 10 2021

Examples

			Let n = 43. The 43rd prime is 191, and 191-42 = 149 and 191+42 = 233 are both prime. However, 42 = 2*3*7 is not a 5-smooth number, so a(43) != 42. But 191-60 = 31 and 191+60 = 251 are both prime numbers, and 60 = 2^2*3*5 is the smallest such 5-smooth number. So a(43) = 60.
		

Crossrefs

Programs

  • Mathematica
    Table[p=Prime[i];j=0;While[j=j+2;If[(PrimeQ[p-j])&&(PrimeQ[p+j]), f=Last[FactorInteger[j]][[1]],f=p];f>5];j,{i,3,72}]

A215642 Primes p such that there is no D such that p+D, p-D, p+2*D, p-2*D are all primes.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 19, 23, 31, 37, 41, 43, 47, 53, 59, 61, 73, 79, 83, 103, 107, 109, 113, 127, 137, 139, 149, 151, 157, 179, 181, 199, 223, 227, 229, 239, 251, 271, 277, 281, 293, 311, 331, 349, 353, 359, 367, 379, 383, 389, 397, 401, 409, 421, 431, 439, 487, 499, 541
Offset: 1

Author

Alex Ratushnyak, Aug 18 2012

Keywords

Comments

Conjecture: a(243)=34613 is the last term.

Examples

			17 doesn't occur in the sequence, because there is D=6: 17-12, 17-6, 17+6 and 17+12 are all primes: 5, 11, 23, 29.
		

Crossrefs

Cf. A078611.

Programs

  • Mathematica
    fQ[p_] := Module[{d = 1}, While[4d < p && !(PrimeQ[p-4d] && PrimeQ[p-2d] && PrimeQ[p+2d] && PrimeQ[p+4d]), d++]; 4d > p]; Select[Prime[Range[4000]], fQ] (* T. D. Noe, Aug 20 2012 *)
  • PARI
    N=10^9;
    default(primelimit,N);
    print1(2,", ");
    { forprime (p=3, N,
        D=2;  D2 = D << 1;
        t = 1;
        while ( p > D2,
            if ( isprime(p+D) & isprime(p-D) &
                 isprime(p+D2) & isprime(p-D2)
            , /* then */
                t=0; break()
            );
            D += 2;  D2 += 4;
        );
        if ( t==1, print1(p,", ") );
    ); }
    /* Joerg Arndt, Aug 20 2012 */

A129758 Smallest prime p such that there are primes q and r with the property that p, q and r form an arithmetic progression and their sum is the same as three times the (n+2)-nd prime number.

Original entry on oeis.org

3, 3, 5, 7, 11, 7, 17, 17, 19, 31, 29, 19, 41, 47, 47, 43, 61, 59, 67, 61, 59, 71, 67, 89, 97, 101, 79, 89, 103, 113, 107, 127, 131, 139, 151, 127, 137, 167, 167, 163, 149, 163, 167, 157, 199, 163, 197, 181, 227, 227, 211, 239, 251, 257, 257, 229, 271, 269
Offset: 1

Author

Giovanni Teofilatto, May 15 2007

Keywords

Comments

The same selection rule as in A078497 applies: if there is more than one prime triple (p,q=p+d,r=q+d) with p+q+r=A001748(n), take p from the triple with minimum d. - R. J. Mathar, May 19 2007

Examples

			3 + 5 + 7 = 15, which is three times the (1+2)th prime number. Thus a(1) = 3.
		

Crossrefs

Programs

  • Maple
    A129758 := proc(n) local p3, i,d,r,p; p3 := ithprime(n) ; i := n+1 ; while true do r := ithprime(i) ; d := r-p3 ; p := p3-d ; if isprime(p) then RETURN(p) ; fi ; i := i+1 ; od ; RETURN(-1) ; end: for n from 3 to 60 do printf("%d, ",A129758(n)) ; od ; # R. J. Mathar, May 19 2007
  • Mathematica
    a[n_]:=Module[{},k=1; While[Not[PrimeQ[Prime[n+1]-k] && PrimeQ[Prime[n+1]+k]], k++ ]; Prime[n + 1] - k]; Table[a[n], {n, 2, 60}]

Formula

A078497(n)-prime(n)=prime(n)-a(n)=d. - R. J. Mathar, May 19 2007
Conjecture: Limit_{N->oo} (Sum_{n=1..N} a(n)) / (Sum_{n=1..N} prime(n+2)) = 1. - Alain Rocchelli, May 01 2024

Extensions

Edited and extended by R. J. Mathar, Giovanni Teofilatto and Stefan Steinerberger, May 19 2007

A177463 The smallest k such that Catalan(n)+k and Catalan(n)-k are both prime.

Original entry on oeis.org

0, 3, 1, 5, 10, 3, 69, 33, 45, 45, 9, 47, 86, 97, 97, 41, 19, 49, 191, 11, 101, 283, 1, 69, 597, 549, 1341, 243, 552, 121, 157, 115, 1341, 1905, 165, 597, 27, 87, 31, 731, 1093, 449, 127, 37, 37, 157, 1145, 587, 317, 659, 1523, 487, 865, 4879, 463, 1351, 4471
Offset: 3

Author

Keywords

Examples

			5 +- 0 -> primes, 14 +- 3 -> primes, 42 +- 1 -> primes, 132 +- 5 -> primes, ...
		

Crossrefs

Programs

  • Maple
    A000108 := proc(n) binomial(2*n,n)/(n+1) ; end proc:
    A047160 := proc(n) for k from 0 to n-1 do if isprime(n-k) and isprime(n+k) then return k; end if; end do: return -1 ; end proc:
    A177463 := proc(n) A047160(A000108(n)) ; end proc:
    seq(A177463(n),n=3..40) ; # R. J. Mathar, Jan 23 2011
  • Mathematica
    g[n_]:=(2n)!/n!/(n+1)!; f[n_]:=Block[{k},If[OddQ[n],k=0,k=1];While[ !PrimeQ[n-k]||!PrimeQ[n+k],k+=2];k]; Table[f[g[n]],{n,3,4*4!}]

Formula

a(n) = A047160(A000108(n)). - R. J. Mathar, Jan 23 2011
Showing 1-10 of 14 results. Next