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

A117387 Prime nearest to 2^n. In case of a tie, choose the smaller.

Original entry on oeis.org

2, 2, 3, 7, 17, 31, 61, 127, 257, 509, 1021, 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573, 2097143, 4194301, 8388617, 16777213, 33554467, 67108859, 134217757, 268435459, 536870909, 1073741827, 2147483647, 4294967291, 8589934583
Offset: 0

Views

Author

Lekraj Beedassy, Mar 11 2006

Keywords

Programs

  • Mathematica
    f[n_] := Block[{k = 0}, While[ !PrimeQ[2^n - k] && !PrimeQ[2^n + k], k++ ]; Min@Select[{2^n - k, 2^n + k}, PrimeQ@# &]]
    pn2n[n_]:=Module[{c=2^n,a,b},a=NextPrime[c,-1];b=NextPrime[c];If[b-c < c-a,b,a]]; Join[{2,2},Table[pn2n[n],{n,2,40}]] (* Harvey P. Dale, Jul 24 2019 *)
  • Python
    from sympy import prevprime, nextprime
    def A117387(n): return (m if (m:=nextprime(k:=1<1 else 2 # Chai Wah Wu, Aug 08 2022

Formula

a(n) = A000079(n) - A059959(n). [Corrected by Georg Fischer, Dec 13 2022]

Extensions

Edited, corrected and extended by Robert G. Wilson v, Mar 14 2006

A060268 Distance of 2n from the closest prime.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 7, 5, 3, 1, 1, 1, 1, 3, 1, 1, 1, 3, 5, 3, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 3, 5, 3, 1, 1, 1, 1, 1, 1, 3, 5, 5, 3, 1, 1
Offset: 2

Views

Author

Labos Elemer, Mar 23 2001

Keywords

Examples

			n=13, 2n=26 surrounded by 23 and 29 which are from 26 in equal distance of 3 and min{3,3}=3=a(13).
		

Crossrefs

Programs

  • Maple
    with(numtheory): [seq(min(nextprime(2*i)-2*i, 2*i-prevprime(2*i)), i=2...256)];
  • Mathematica
    a[n_] := Min[NextPrime[2*n] - 2*n, 2*n - NextPrime[2*n, -1]]; Array[a, 100, 2] (* Amiram Eldar, Sep 16 2020 *)
  • PARI
    a(n) = min(2*n - precprime(2*n-1), nextprime(2*n+1) - 2*n); \\ Michel Marcus, Sep 16 2020

Formula

a(n) = min(A049653(n), A060266(n)). - Michel Marcus, Sep 16 2020

A060272 Distance from n^2 to closest prime.

Original entry on oeis.org

1, 1, 2, 1, 2, 1, 2, 3, 2, 1, 6, 5, 2, 1, 2, 1, 4, 7, 2, 1, 2, 3, 6, 1, 6, 1, 2, 3, 2, 7, 6, 3, 2, 3, 2, 1, 2, 3, 2, 1, 12, 5, 2, 3, 2, 3, 2, 5, 2, 3, 8, 3, 6, 1, 2, 1, 2, 3, 10, 7, 2, 3, 2, 3, 4, 1, 4, 3, 2, 3, 2, 5, 4, 1, 2, 3, 2, 5, 6, 3, 2, 5, 6, 1, 4, 3, 4, 3, 2, 1, 6, 3, 2, 1, 4, 5, 4, 3, 2, 7, 8, 5, 2
Offset: 1

Views

Author

Labos Elemer, Mar 23 2001

Keywords

Examples

			n=1: n^2=1 has next prime 2, so a(1)=1;
n=11: n^2=121 is between primes {113,127} and closer to 127, thus a(11)=6.
		

Crossrefs

Programs

  • Maple
    seq((s-> min(nextprime(s)-s, `if`(s>2, s-prevprime(s), [][])))(n^2), n=1..256);  # edited by Alois P. Heinz, Jul 16 2017
  • Mathematica
    Table[Function[k, Min[k - #, NextPrime@ # - k] &@ If[n == 1, 0, Prime@ PrimePi@ k]][n^2], {n, 103}] (* Michael De Vlieger, Jul 15 2017 *)
    Min[#-NextPrime[#,-1],NextPrime[#]-#]&/@(Range[110]^2) (* Harvey P. Dale, Jun 26 2021 *)
  • PARI
    a(n) = if (n==1, nextprime(n^2) - n^2, min(n^2 - precprime(n^2), nextprime(n^2) - n^2)); \\ Michel Marcus, Jul 16 2017

Formula

a(n) = abs(A000290(n) - A113425(n)) = abs(A000290(n) - A113426(n)). - Reinhard Zumkeller, Oct 31 2005
Showing 1-3 of 3 results.