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!)
A323213 Nearest prime to the median of the primes below 10^n. 0

%I #26 Nov 14 2020 08:37:17

%S 5,41,439,4523,46411,470303,4751053,47868179,481346903,4834216447,

%T 48507378197,486425324491,4875521711327,48850585043591,

%U 489323461383733,4900321995437591,49065251868835099,491200019422325489,4916868348839249987,49212253916770634411

%N Nearest prime to the median of the primes below 10^n.

%H Kim Walisch, <a href="https://github.com/kimwalisch/primecount">primecount</a>.

%F a(n) = prime(floor(A006880(n) / 2) + 1). - _David A. Corneth_, Mar 19 2019

%e From _David A. Corneth_, Mar 19 2019: (Start)

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

%e 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)

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

%o (Julia) using Statistics, Primes

%o function MedianPrimes(n)

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

%o isprime(med) && return med

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

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

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

%o (PARI) a(n) = pi = primepi(10^n); prime(pi \ 2 + 1) \\ _David A. Corneth_, Mar 19 2019

%Y Cf. A000040, A000720, A006880.

%K nonn,more

%O 1,1

%A _Peter Luschny_, Mar 19 2019

%E a(11) from _David A. Corneth_, Mar 19 2019

%E a(12)-a(19) using Kim Walisch's primecount, from _Amiram Eldar_, Mar 20 2019

%E a(20) from _Jinyuan Wang_, Nov 14 2020

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 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)