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!)
A349791 a(n) is the median of the primes between n^2 and (n+1)^2. 2
6, 12, 19, 30, 42, 59, 72, 89, 107, 134, 157, 181, 205, 236, 271, 311, 348, 381, 421, 461, 503, 560, 601, 650, 701, 754, 821, 870, 933, 994, 1051, 1113, 1193, 1268, 1319, 1423, 1482, 1559, 1624, 1723, 1801, 1884, 1993, 2081, 2148, 2267, 2357, 2444, 2549, 2663 (list; graph; refs; listen; history; text; internal format)
OFFSET
2,1
COMMENTS
The median of an even number of values is assumed to be defined as the arithmetic mean of the two central elements in their sorted list. The special case of the primes 2 and 3 in the interval [1,4] is excluded because their median would be 5/2.
LINKS
MATHEMATICA
Table[Median@Select[Range[n^2, (n+1)^2], PrimeQ], {n, 2, 51}] (* Giorgos Kalogeropoulos, Dec 05 2021 *)
PROG
(PARI) medpsq(n) = {my(p1=nextprime(n^2), p2=precprime((n+1)^2), np1=primepi(p1), np2=primepi(p2), nm=(np1+np2)/2);
if(denominator(nm)==1, prime(nm), (prime(nm-1/2)+prime(nm+1/2))/2)};
for(k=2, 51, print1(medpsq(k), ", "))
(Python)
from sympy import primerange
from statistics import median
def a(n): return int(median(primerange(n**2, (n+1)**2)))
print([a(n) for n in range(2, 52)]) # Michael S. Branicky, Dec 05 2021
(Python)
from sympy import primepi, prime
def A349791(n):
b = primepi(n**2)+primepi((n+1)**2)+1
return (prime(b//2)+prime((b+1)//2))//2 if b % 2 else prime(b//2) # Chai Wah Wu, Dec 05 2021
CROSSREFS
Sequence in context: A365702 A215342 A146923 * A256977 A087883 A218438
KEYWORD
nonn
AUTHOR
Hugo Pfoertner, Dec 05 2021
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 July 1 14:19 EDT 2024. Contains 373917 sequences. (Running on oeis4.)