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

A020483 Least prime p such that p+2n is also prime.

Original entry on oeis.org

2, 3, 3, 5, 3, 3, 5, 3, 3, 5, 3, 7, 5, 3, 3, 7, 5, 3, 5, 3, 3, 5, 3, 7, 5, 3, 7, 5, 3, 3, 7, 5, 3, 5, 3, 3, 7, 5, 3, 5, 3, 7, 5, 3, 13, 7, 5, 3, 5, 3, 3, 5, 3, 3, 5, 3, 19, 13, 11, 13, 7, 5, 3, 5, 3, 7, 5, 3, 3, 11, 11, 7, 5, 3, 3, 7, 5, 3, 7, 5, 3, 5, 3, 7, 5, 3, 7, 5, 3, 3, 11, 11, 7, 5, 3, 3, 5, 3, 3, 13, 11, 31, 7
Offset: 0

Views

Author

Keywords

Comments

It is conjectured that a(n) always exists. a(n) has been computed for n < 5 * 10^11, with largest value a(248281210271) = 3307. - Jens Kruse Andersen, Nov 28 2004
If a(n) = a(n+1) = k, then 2*n + k and 2*(n+1) + k are twin primes. - Ya-Ping Lu, Sep 22 2020

Examples

			Given n = 2, we see that 2 + 2n = 6 = 2 * 3, but 3 + 2n = 7, which is prime, so a(2) = 3.
Given n = 3, we see that 2 + 2n = 8 = 2^3 and 3 + 2n = 9 = 3^2, but 5 + 2n = 11, which is prime, so a(3) = 5.
		

Crossrefs

Cf. A101045, A239392 (record values).
It is likely that A054906 is an identical sequence, although this seems to have not yet been proved. - N. J. A. Sloane, Feb 06 2017

Programs

  • GAP
    P:=Filtered([1..10000],IsPrime);;
    a:=List(List([0..110],n->Filtered(P,i->IsPrime(i+2*n))),Minimum); # Muniru A Asiru, Mar 26 2018
  • Haskell
    a020483 n = head [p | p <- a000040_list, a010051' (p + 2 * n) == 1]
    -- Reinhard Zumkeller, Nov 29 2014
    
  • Maple
    A020483 := proc(n)
        local p;
        p := 2;
        while true do
            if isprime(p+2*n) then
                return p;
            end if;
            p := nextprime(p) ;
        end do:
    end proc:
    seq(A020483(n),n=0..40); # R. J. Mathar, Sep 23 2016
  • Mathematica
    Table[j = 1; found = False; While[!found, j++; found = PrimeQ[Prime[j] + 2i]]; Prime[j], {i, 200}]
    leastPrimep2n[n_] := Block[{k = 1, p, q = 2 n}, While[p = Prime@k; !PrimeQ[p + q], k++]; p]; Array[leastPrimep2n, 102] (* Robert G. Wilson v, Mar 26 2008 *)
  • PARI
    a(n)=forprime(p=2,,if(isprime(p+2*n), return(p))) \\ Charles R Greathouse IV, Mar 19 2014
    

Formula

If a(n) exists, a(n) < 2n, which of course is a great overestimate. - T. D. Noe, Jul 16 2002
a(n) = A087711(n) - n. - Zak Seidov, Nov 28 2007
a(n) = A020484(n) - 2n. - Zak Seidov, May 29 2014
a(n) = 2 if and only if n = 0. - Alonso del Arte, Mar 14 2018

Extensions

a(0)=2 added by N. J. A. Sloane, Apr 25 2015

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

A282690 a(n) is the smallest number m, such that m+n is the next prime and m-n is the previous prime.

Original entry on oeis.org

4, 5, 26, 93, 144, 53, 120, 1839, 532, 897, 1140, 211, 2490, 2985, 4312, 5607, 1344, 9569, 30612, 19353, 16162, 15705, 81486, 16787, 31932, 19635, 35644, 82101, 44322, 43361, 34092, 89721, 162176, 134547, 173394, 31433, 404634, 212739, 188068, 542643, 265662
Offset: 1

Views

Author

Daniel Suteu, Feb 20 2017

Keywords

Examples

			For n = 6, a(6) = 53, because the next prime after 53 is 59 and the previous prime before 53 is 47, where both have an equal distance of 6 from 53, which is the smallest number with this property.
		

Crossrefs

Programs

  • Mathematica
    Table[k = 1; While[Nand[k - n == NextPrime[k, -1], k + n == NextPrime@ k], k++]; k, {n, 41}] (* Michael De Vlieger, Feb 20 2017 *)
  • Perl
    use ntheory qw(:all);
    for (my $k = 1 ; ; ++$k) {
        for (my $n = 1 ; ; ++$n) {
            my $p = prev_prime($n) || next;
            my $q = next_prime($n);
            if ($n-$p == $k and $q-$n == $k) {
                printf("%s %s\n", $k, $n);
                last;
            }
        }
    }

A137169 a(0) = 2; for n>0, a(n) = smallest number m > a(n-1) such that both m-n and m+n are primes.

Original entry on oeis.org

2, 4, 5, 8, 9, 12, 13, 24, 39, 50, 51, 72, 85, 96, 117, 122, 123, 156, 175, 192, 213, 218, 219, 234, 247, 252, 255, 256, 279, 360, 367, 378, 399, 400, 423, 432, 455, 486, 525, 530, 531, 612, 619, 630, 657, 664, 687, 774, 775, 810, 837, 860, 915, 930, 937, 942
Offset: 0

Views

Author

Keywords

Comments

A variant of A087711. - R. J. Mathar, Apr 09 2008

Examples

			4-1=3 prime, 4+1=5 prime; 5-2=3, 5+2=7; 8-3=5, 8+3=11; 9-4=5, 9+4=13;
		

Crossrefs

See A087711 for another version.

Programs

  • Maple
    A137169 := proc(n) option remember ; if n = 0 then RETURN(2) ; fi ; for a from A137169(n-1)+1 do if isprime(a-n) and isprime(a+n) then RETURN(a) ; fi ; od: end: seq(A137169(n),n=0..80) ; # R. J. Mathar, Apr 09 2008
  • Mathematica
    s = ""; k = 0; For[i = 2, i < 22^2, If[PrimeQ[i - k] && PrimeQ[i + k], s = s <> ToString[i] <> ","; k++ ]; i++ ]; Print[s]

Extensions

More terms from R. J. Mathar, Apr 09 2008
Typo in Mathematica code corrected by Vincenzo Librandi, Jun 15 2013

A216898 a(n) = smallest number k such that both k - n^2 and k + n^2 are primes.

Original entry on oeis.org

2, 4, 7, 14, 21, 28, 43, 52, 67, 86, 111, 150, 149, 180, 201, 232, 267, 312, 329, 366, 411, 446, 487, 532, 587, 654, 705, 742, 787, 852, 911, 972, 1029, 1118, 1185, 1242, 1313, 1372, 1473, 1528, 1603, 1692, 1769, 1852, 1941, 2032, 2127, 2212, 2317, 2412, 2503
Offset: 0

Views

Author

Zak Seidov, Sep 19 2012

Keywords

Comments

Note that a(11) = 150 and a(12) = 149. Up to n = 10^6, this is the only case where a(n) > a(n+1). What about general case of a(n) < a(n+1)?
First differences are almost linear with n hence the only case with a(n) > a(n+1) is n = 11. - Zak Seidov, May 19 2014

Examples

			a(11) = 150 because both 150 - 11^2 = 29 and 150 + 11^2 = 271 are primes.
a(12) = 149 because both 149 - 12^2 = 5 and 149 + 12^2 = 293 are primes.
		

Crossrefs

Cf. A087711.

Programs

  • Mathematica
    Table[If[n < 1, 2, m = n^2 + 1; While[!PrimeQ[m - n^2] || !PrimeQ[m + n^2], m = m + 2]; m], {n, 0, 100}]

Formula

a(n) = A087711(n^2). - T. D. Noe, Sep 19 2012

A282687 a(n) = strictly increasing number m, such that m+n is the next prime and m-n is the previous prime.

Original entry on oeis.org

4, 5, 26, 93, 144, 157, 300, 1839, 1922, 3099, 3240, 4189, 5544, 5967, 6506, 10815, 11760, 12871, 30612, 33267, 35002, 36411, 81486, 86653, 95676, 103263, 106060, 153219, 181332, 189097, 190440, 288615, 294596, 326403, 399318, 507253, 515004, 570291, 642320
Offset: 1

Views

Author

Daniel Suteu, Feb 20 2017

Keywords

Examples

			For n = 5, a(5) = 144, because the next prime after 144 is 149 and the previous prime before 144 is 139, where both have an equal distance of 5 from 144.
		

Crossrefs

Programs

  • Mathematica
    a = {}; Do[If[n == 1, k = 1, k = Max@ a + 1]; While[Nand[k - n == NextPrime[k, -1], k + n == NextPrime@ k], k++]; AppendTo[a, k], {n, 41}]; a (* Michael De Vlieger, Feb 20 2017 *)
  • Perl
    use ntheory qw(:all);
    for (my ($n, $k) = (1, 1) ; ; ++$n) {
        my $p = prev_prime($n) || next;
        my $q = next_prime($n);
        if ($n-$p == $k and $q-$n == $k) {
            printf("%s %s\n", $k++, $n);
        }
    }

A097523 a(n) = least k such that k - prime(n) and k + prime(n) are both prime.

Original entry on oeis.org

5, 8, 8, 10, 18, 16, 20, 22, 30, 32, 36, 42, 48, 46, 50, 56, 72, 66, 70, 78, 76, 84, 90, 92, 100, 132, 108, 120, 114, 116, 130, 138, 140, 142, 162, 156, 160, 168, 170, 176, 210, 186, 198, 196, 200, 202, 222, 226, 230, 232, 246, 252, 246, 258, 264, 294, 272, 276
Offset: 1

Views

Author

Pierre CAMI, Aug 27 2004

Keywords

Examples

			Prime(10) = 29; both 32 - 29 = 3 and 32 + 29 = 61 are prime, and 32 is the smallest integer for which this is the case, so a(10) = 32.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local p, k;
      p:= ithprime(n);
      for k from p+1 by 2 do
        if isprime(k+p) and isprime(k-p) then return k fi
      od
    end proc:
    f(1):= 5:
    map(f, [$1..100]); # Robert Israel, Jul 26 2015
  • Mathematica
    f[n_] := Block[{k = Prime[n], p = Prime[n]}, While[ !PrimeQ[k - p] || !PrimeQ[k + p], k++ ]; k]; Table[ f[n], {n, 60}] (* Robert G. Wilson v, Aug 28 2004 *)

Formula

a(n) = A087711(A000040(n)). - Robert Israel, Jul 26 2015

Extensions

Corrected by Robert G. Wilson v, Aug 28 2004

A323728 a(n) is the smallest number k such that both k-2*n and k+2*n are squares.

Original entry on oeis.org

2, 5, 10, 8, 26, 13, 50, 20, 18, 29, 122, 25, 170, 53, 34, 32, 290, 45, 362, 41, 58, 125, 530, 52, 50, 173, 90, 65, 842, 61, 962, 80, 130, 293, 74, 72, 1370, 365, 178, 89, 1682, 85, 1850, 137, 106, 533, 2210, 100, 98, 125, 298, 185, 2810, 117, 146, 113, 370
Offset: 1

Views

Author

Daniel Suteu, Jan 25 2019

Keywords

Comments

When n is a prime number, a(n) is greater than all the previous terms.
If n = 4*x*y, then a(n) is the smallest integer solution of the form 4*(x^2 + y^2), with rational values x and y.

Examples

			For n = 3, a(3) = 10, which is the smallest integer k such that k+2*n and k-2*n are both squares: 10+2*3 = 4^2 and 10-2*3 = 2^2.
For n=1..10, the following {a(n)-2*n, a(n)+2*n} pairs of squares are produced: {0, 4}, {1, 9}, {4, 16}, {0, 16}, {16, 36}, {1, 25}, {36, 64}, {4, 36}, {0, 36}, {9, 49}.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local d;
    d:= max(select(t -> t^2 <= n, numtheory:-divisors(n)));
    d^2 + (n/d)^2
    end proc:
    map(f, [$1..100]); # Robert Israel, Feb 17 2019
  • Mathematica
    Array[Block[{k = 1}, While[Nand @@ Map[IntegerQ, Sqrt[k + 2 {-#, #}]], k++]; k] &, 57] (* Michael De Vlieger, Feb 17 2019 *)
  • PARI
    a(n) = for(k=2*n, oo, if(issquare(k+2*n) && issquare(k-2*n), return(k)));
    
  • PARI
    a(n) = my(d=divisors(n)); vecmin(vector(#d, k, 4*((d[k]/2)^2 + (n/d[k]/2)^2)));

Formula

a(n^2) = 2 * n^2.
a(p) = p^2 + 1, for p prime.
a(n) = A063655(n)^2 - 2*n.
a(n) = A056737(n)^2 + 2*n.
a(n!) = A061057(n)^2 + 2*n!.
a(n) = A033676(n)^2 + A033677(n)^2. - Robert Israel, Feb 17 2019
a(n) = Min_{d|n} ((n/d)^2 + d^2). - Ridouane Oudra, Mar 17 2024

A296341 Least number k such that the arithmetic derivatives of the composite numbers k-n and k+n are equal.

Original entry on oeis.org

138004, 23, 2012, 136, 72708, 22, 1449858, 41, 264, 28, 1116, 107, 112, 44, 11752, 292, 1047798, 68, 88212, 71, 2478418, 54, 452, 119, 220, 92, 582, 592, 40284, 191, 329958, 89, 1600550, 602, 516798, 151, 2952, 140, 11434, 298, 125714, 212, 39654, 896, 822, 126
Offset: 1

Views

Author

Paolo P. Lava, Dec 12 2017

Keywords

Comments

If the limitation of searching only for composite numbers k-n and k+n is removed, the terms we get are the average of two primes.

Examples

			a(1) = 138004 because it is the least number k such that the composites k-1 and k+1 have arithmetic derivatives (k-1)' = (k+1)'. We see that (138004 - 1)' = (138004 + 1)' = 47351;
a(2) = 23 because it is the least number k such that the composites k - 2 and k+2 have arithmetic derivatives (k-2)' = (k+2)'. We see that (23 - 1)' = (23 + 1).
		

Crossrefs

Programs

  • Maple
    with(numtheory): P:=proc(q) local a,h,n,p; for h from 1 to q do
    for n from h to q do if not isprime(n-h) and
    (n-h)*add(op(2,p)/op(1,p),p=ifactors(n-h)[2])=
    (n+h)*add(op(2,p)/op(1,p),p=ifactors(n+h)[2])
    then print(n); break; fi; od; od; end: P(10^9);
  • Mathematica
    ad[n_] := With[{f = FactorInteger[n]}, n*Total[f[[All, 2]]/f[[All, 1]]]];
    okQ[n_, k_] := If[Not[CompositeQ[k-n] && CompositeQ[k+n]], False, ad[k-n] == ad[k+n]];
    a[n_] := For[k = 1, True, k++, If[okQ[n, k], Print["a(", n, ") = ", k]; Return[k]]];
    Array[a, 46] (* Jean-François Alcover, Dec 20 2017 *)
Showing 1-9 of 9 results.