login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A247351 Nearest prime to Pi*10^(n-1). 1
3, 31, 313, 3137, 31397, 314159, 3141601, 31415899, 314159257, 3141592661, 31415926541, 314159265359, 3141592653581, 31415926535879, 314159265358951, 3141592653589771, 31415926535897921, 314159265358979347, 3141592653589793239, 31415926535897932363 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
COMMENTS
Lim_{n->infinity} a(n)/10^(n-1) = Pi.
Demonstration: If gap_a(p) (resp. gap_b(p)) denotes the gap between a prime p and the next (resp. preceding) prime, we have by definition |Pi*10^(n-1)-a(n)| < max(gap_a(a(n)),gap_b(a(n)))/2. Now, it is known from results on prime gaps (e.g., Ingham, 1937) that gap_a(p) and gap_b(p) are O(p^theta) for some theta < 1; thus |Pi*10^(n-1)-a(n)| = O(a(n)^theta) and the result.
LINKS
MAPLE
a:= proc(n) local f, h, p, q; Digits:= 20+n;
f:= evalf(Pi*10^(n-1)); h:= round(f);
if isprime(h) then return h fi;
p:= prevprime(h); q:= nextprime(h);
`if`(f-p < q-f, p, q)
end:
seq(a(n), n=1..30); # Alois P. Heinz, Sep 24 2014
MATHEMATICA
a[n_]:=If[10^(n-1)*Pi<1/2(NextPrime[10^(n-1)*Pi, -1]+NextPrime[10^(n-1)*Pi]), NextPrime[10^(n-1)*Pi, -1], NextPrime[10^(n-1)*Pi]]; Table[a[n], {n, 20}] (* Farideh Firoozbakht, Sep 18 2014, Sep 24 2014 *)
np[n_]:=With[{c=Pi 10^n}, Nearest[{NextPrime[c, -1], NextPrime[c]}, c]]; Array[np, 20, 0]//Flatten (* Harvey P. Dale, Feb 01 2024 *)
PROG
(Python)
from sympy import isprime, nextprime, prevprime, S
def a(n):
target = int(S.Pi*10**(n-1))
if isprime(target): return target
before, after = prevprime(target), nextprime(target)
return before if target-before <= after-target else after
print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Mar 31 2021
CROSSREFS
Cf. A000796 (Pi).
Sequence in context: A111137 A037785 A037589 * A089289 A011545 A011546
KEYWORD
nonn
AUTHOR
EXTENSIONS
a(7)-a(14) from Farideh Firoozbakht, Sep 18 2014
a(15)-a(20) from Alois P. Heinz, Sep 24 2014
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 00:30 EDT 2024. Contains 371917 sequences. (Running on oeis4.)