login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A323213 Nearest prime to the median of the primes below 10^n. 0
5, 41, 439, 4523, 46411, 470303, 4751053, 47868179, 481346903, 4834216447, 48507378197, 486425324491, 4875521711327, 48850585043591, 489323461383733, 4900321995437591, 49065251868835099, 491200019422325489, 4916868348839249987 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

LINKS

Table of n, a(n) for n=1..19.

Kim Walisch, primecount.

FORMULA

a(n) = prime(floor(A006880(n) / 2) + 1). - David A. Corneth, Mar 19 2019

EXAMPLE

From David A. Corneth, Mar 19 2019: (Start)

There are 25 primes <= 10^2 = 100 so a(2) is the (25 + 1)/2th = 13th prime, being 41.

There are 168 primes <= 10^3 = 1000 so a(3) is the prime closest to the average of prime(84) = 433 and prime(85) = 439. That average is 436, equally distant from both primes. So the largest is chosen. This disables the need to compute the median and we can immediately say that a(3) = prime(168 / 2 + 1) = 439. (End)

MATHEMATICA

a[n_] := Prime[Floor[PrimePi[10^n]/2] + 1]; Array[a, 10] (* Amiram Eldar, Mar 20 2019 *)

PROG

(Julia) using Statistics, Primes

function MedianPrimes(n)

    med = Int64(round(median(primes(10^n))))

    isprime(med) && return med

    prevmed = prevprime(med); nextmed = nextprime(med)

    abs(med - prevmed) < abs(med - nextmed) ? prevmed : nextmed end

println([MedianPrimes(n) for n in 1:12])

(PARI) a(n) = pi = primepi(10^n); prime(pi \ 2 + 1) \\ David A. Corneth, Mar 19 2019

CROSSREFS

Cf. A000040, A000720, A006880.

Sequence in context: A218219 A140095 A259609 * A083073 A115257 A225095

Adjacent sequences:  A323210 A323211 A323212 * A323214 A323215 A323216

KEYWORD

nonn,more

AUTHOR

Peter Luschny, Mar 19 2019

EXTENSIONS

a(11) from David A. Corneth, Mar 19 2019

a(12)-a(19) using Kim Walisch's primecount, from Amiram Eldar, Mar 20 2019

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 15 05:43 EDT 2019. Contains 328026 sequences. (Running on oeis4.)