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

A304874 Greatest prime p1 < p2 such that n^2 = (p1 + p2)/2 and p2 is prime.

Original entry on oeis.org

3, 7, 13, 19, 31, 37, 61, 79, 97, 103, 139, 157, 193, 223, 241, 271, 317, 349, 379, 439, 421, 487, 521, 619, 661, 719, 757, 829, 881, 883, 1009, 1087, 1063, 1213, 1291, 1291, 1429, 1511, 1579, 1669, 1741, 1831, 1879
Offset: 2

Views

Author

Hugo Pfoertner, May 20 2018

Keywords

Comments

Each square > 1 can be written as the average of 2 primes p1 < p2. a(n) gives the greatest prime p1 such that n^2 = (p1 + p2) / 2. The corresponding p2 is provided in A304875.

Examples

			a(2) = 3 because 2^2 = 4 = (3 + 5)/2,
a(7) = 37 because 7^2 = 49 = (37 + 61)/2 and none of the primes p1 = 41, 43 or 47 leads to a prime p2.
		

Crossrefs

Formula

a(n) = n^2 - A172989(n) = A304875(n) - 2*A172989(n).

A304875 Least prime p2 > p1 such that n^2 = (p1 + p2)/2 and p1 is prime.

Original entry on oeis.org

5, 11, 19, 31, 41, 61, 67, 83, 103, 139, 149, 181, 199, 227, 271, 307, 331, 373, 421, 443, 547, 571, 631, 631, 691, 739, 811, 853, 919, 1039, 1039, 1091, 1249, 1237, 1301, 1447, 1459, 1531, 1621, 1693, 1787, 1867
Offset: 2

Views

Author

Hugo Pfoertner, May 20 2018

Keywords

Comments

Each square > 1 can be written as the average of 2 primes p1 < p2. a(n) gives the least prime p2 such that n^2 = (p1 + p2) / 2. The corresponding p1 is provided in A304874.

Examples

			a(2) = 5 because 2^2 = 4 = (3 + 5)/2,
a(7) = 61 because 7^2 = 49 = (37 + 61)/2 and p2 = 53 or p2 = 59 don't lead to a prime p1.
		

Crossrefs

Formula

a(n) = n^2 + A172989(n) = A304874(n) + 2*A172989(n).

A172990 a(n) is the smallest k such that the two numbers n^3 +- k are primes.

Original entry on oeis.org

3, 4, 3, 12, 17, 6, 9, 10, 9, 30, 5, 54, 33, 14, 3, 24, 11, 168, 81, 20, 9, 60, 17, 18, 3, 80, 9, 18, 73, 192, 75, 14, 63, 54, 7, 54, 255, 38, 303, 42, 11, 114, 63, 4, 33, 180, 5, 30, 93, 28, 21, 84, 115, 18, 15, 40, 9, 228, 61, 318, 171, 4, 93, 42, 5, 24, 9, 70, 51, 72, 49, 444, 3
Offset: 2

Views

Author

Keywords

Examples

			Both 2^3 - 3 = 5 and 2^3 + 3 = 11 are prime, and there is no positive number k < 3 for which this is the case, so a(2) = 3; similarly,
both 3^3 -  4 =  23 and 3^3 +  4 =  31 are prime;
both 4^3 -  3 =  61 and 4^3 +  3 =  67 are prime;
both 5^3 - 12 = 113 and 5^3 + 12 = 137 are prime.
		

Crossrefs

Programs

  • MATLAB
    m=1; for n=2:80 for k=1:1000 if and(isprime(n^3-k)==1, isprime(n^3+k)==1) sol(m)=k; m=m+1; break; end; end; end; sol % Marius A. Burtea, Jul 31 2019
  • Magma
    sol:=[]; for m in [2..80] do k:=1; while k le 1000 and not(IsPrime(m^3-k) and IsPrime(m^3+k)) do k:=k+1; end while; sol[m-1]:=k; end for; sol; // Marius A. Burtea, Jul 31 2019
    
  • 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^3],{n,2,40}]

Extensions

Name and Example section edited by Jon E. Schoenfield, Jul 31 2019

A304905 Greatest difference d such that both n^2 - d and n^2 + d are primes.

Original entry on oeis.org

1, 4, 13, 22, 31, 30, 45, 76, 97, 118, 139, 162, 193, 218, 253, 282, 319, 358, 397, 436, 453, 522, 553, 612, 645, 724, 765, 828, 889, 918, 1005, 1072, 1153, 1222, 1283, 1362, 1413, 1516, 1587, 1678, 1753, 1842, 1917
Offset: 2

Views

Author

Hugo Pfoertner, May 20 2018

Keywords

Examples

			a(2) = 1 because 2^2 - 1 = 3 and 2^2 + 1 = 5 are primes.
a(7) = 30 because 7^2 - 30 = 19 and 7^2 + 30 = 79 is the pair with maximum difference. All greater differences lead to at least one composite, i.e., 49 + 32 = 81, 49 - 34 = 15, 49 + 36 = 85, 49 + 38 = 87, 49 - 40 = 9, 49 + 42 = 91 = 7*13, 49 + 44 = 93 = 3*31, 49 + 46 = 95, and 49 - 48 = 1 is not a prime.
		

Crossrefs

Programs

  • PARI
    a304903(n) = forprime(p=3, , if(ispseudoprime(2*n^2-p), return(p)))
    a(n) = n^2 - a304903(n) \\ Felix Fröhlich, May 20 2018

Formula

a(n) = (A304904(n) - A304903(n))/2 = n^2 - A304903(n) = A304904(n) - n^2.

A239146 Smallest k>0 such that n +/- k and n^2 +/- k are all prime. a(n) = 0 if no such number exists.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 5, 0, 3, 2, 0, 0, 13, 12, 0, 2, 0, 0, 0, 6, 15, 10, 0, 12, 0, 0, 15, 20, 0, 12, 5, 0, 15, 22, 21, 12, 0, 0, 0, 14, 27, 0, 35, 0, 0, 8, 15, 0, 0, 24, 27, 0, 0, 48, 7, 48, 0, 50, 3, 6, 7, 0, 0, 28, 0, 18, 0, 0, 27, 34
Offset: 1

Views

Author

Derek Orr, Mar 11 2014

Keywords

Comments

a(n) is always smaller than n due to the requirement on n-k.

Examples

			8 +/- 1 (7 and 9) and 8^2 +/- 1 (63 and 65) are not all prime. 8 +/- 2 (6 and 10) and 8^2 +/- 2 (62 and 66) are not all prime. However, 8 +/- 3 (5 and 11) and 8^2 +/- 3 (61 and 67) are all prime. Thus, a(8) = 3.
		

Crossrefs

Programs

  • Maple
    A239146 := proc(n)
        local k ;
        for k from 1 do
            if n-k <= 1 then
                return 0;
            end if;
            if isprime(n+k) and isprime(n-k) and isprime(n^2+k)
                and isprime(n^2-k) then
                return k;
            end if;
        end do;
    end proc:
    seq(A239146(n),n=1..80) ; # R. J. Mathar, Mar 12 2014
  • Mathematica
    a[n_] := Catch@ Block[{k = 1}, While[k < n, And @@ PrimeQ@ {n+k, n-k, n^2+k, n^2-k} && Throw@k; k++]; 0]; Array[a, 75] (* Giovanni Resta, Mar 13 2014 *)
  • Python
    import sympy
    from sympy import isprime
    def c(n):
      for k in range(1,n):
        if isprime(n+k) and isprime(n-k) and isprime(n**2+k) and isprime(n**2-k):
          return k
    n = 1
    while n < 100:
      if c(n) == None:
        print(0)
      else:
        print(c(n))
      n += 1

A305125 Number of ways to express n^2 as average of two primes p1 < p2.

Original entry on oeis.org

0, 1, 2, 2, 4, 6, 3, 3, 10, 8, 8, 17, 9, 11, 27, 11, 12, 27, 14, 21, 39, 17, 19, 36, 28, 22, 48, 25, 24, 75, 30, 25, 68, 35, 56, 68, 37, 40, 93, 54, 43, 103, 42, 52, 125, 51, 49, 117, 64, 76, 130, 63, 56, 135, 99, 78, 151, 76, 73, 198
Offset: 1

Views

Author

Hugo Pfoertner, May 26 2018

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_]:=Length[Select[2 n - Prime[Range[2, PrimePi[n]]], PrimeQ]]; Table[f[n^2], {n, 60}] (* Vincenzo Librandi, May 26 2018 *)
  • PARI
    for (n=1,60,k=0;n2=2*n*n;forprime(p=3,n2/2,if(isprime(n2-p),k++));print1(k,", "))

Formula

a(n) = A002375(n^2).

A177460 Smallest k such that A000217(n)+k and A000217(n)-k are both prime.

Original entry on oeis.org

0, 1, 3, 2, 2, 9, 5, 2, 12, 5, 5, 12, 2, 7, 27, 4, 8, 9, 13, 2, 24, 5, 7, 12, 2, 5, 27, 4, 2, 75, 19, 38, 18, 11, 7, 30, 2, 7, 9, 2, 16, 63, 7, 4, 12, 25, 5, 12, 16, 35, 51, 2, 2, 9, 13, 16, 12, 17, 41, 60, 20, 13, 51, 8, 32, 9, 5, 22, 18, 35, 19, 12, 22, 7, 75, 34, 2, 93, 11, 2, 30, 25, 11
Offset: 2

Views

Author

Keywords

Examples

			3+-0->primes. 6+-1->primes. 10+-3->primes. 15+-2->primes,..
		

Crossrefs

Programs

  • Mathematica
    f[n_]:=Block[{k},If[OddQ[n],k=0,k=1];While[ !PrimeQ[n-k]||!PrimeQ[n+k], k+=2];k]; Table[f[n*(n+1)/2],{n,2,5!}]

Extensions

Definition rephrased and offset adapted by R. J. Mathar, Aug 15 2010

A177462 Smallest k such that A000125(n)+k and A000125(n)-k are both prime.

Original entry on oeis.org

1, 3, 2, 3, 1, 3, 4, 21, 3, 9, 18, 5, 9, 55, 36, 5, 21, 57, 30, 9, 7, 21, 14, 33, 49, 3, 150, 39, 117, 19, 12, 11, 27, 17, 66, 27, 21, 87, 10, 75, 7, 21, 14, 33, 39, 45, 30, 47, 3, 5, 210, 49, 27, 3, 30, 63, 5, 21, 58, 69, 5, 9, 168, 153, 9, 37, 204, 23, 33, 41, 78, 21, 123, 3, 100
Offset: 2

Views

Author

Keywords

Examples

			4+-1->primes. 8+-3->primes. 15+-2->primes. 26+-3->primes,..
		

Crossrefs

Programs

  • Mathematica
    g[n_]:=(n+1)*(n^2-n+6)/6; f[n_]:=Block[{k},If[OddQ[n],k=2,k=1];While[ !PrimeQ[n-k]||!PrimeQ[n+k],k+=2];k]; Table[f[g[n]],{n,2,5!}]

Extensions

Definition rephrased and offset adapted by R. J. Mathar, Aug 15 2010
Showing 1-8 of 8 results.