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.

A349791 a(n) is the median of the primes between n^2 and (n+1)^2.

This page as a plain text file.
%I A349791 #21 Dec 27 2022 08:32:59
%S A349791 6,12,19,30,42,59,72,89,107,134,157,181,205,236,271,311,348,381,421,
%T A349791 461,503,560,601,650,701,754,821,870,933,994,1051,1113,1193,1268,1319,
%U A349791 1423,1482,1559,1624,1723,1801,1884,1993,2081,2148,2267,2357,2444,2549,2663
%N A349791 a(n) is the median of the primes between n^2 and (n+1)^2.
%C A349791 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.
%H A349791 Hugo Pfoertner, <a href="/A349791/b349791.txt">Table of n, a(n) for n = 2..10000</a>
%t A349791 Table[Median@Select[Range[n^2,(n+1)^2],PrimeQ],{n,2,51}] (* _Giorgos Kalogeropoulos_, Dec 05 2021 *)
%o A349791 (PARI) medpsq(n) = {my(p1=nextprime(n^2), p2=precprime((n+1)^2), np1=primepi(p1), np2=primepi(p2), nm=(np1+np2)/2);
%o A349791 if(denominator(nm)==1, prime(nm), (prime(nm-1/2)+prime(nm+1/2))/2)};
%o A349791 for(k=2,51,print1(medpsq(k),", "))
%o A349791 (Python)
%o A349791 from sympy import primerange
%o A349791 from statistics import median
%o A349791 def a(n): return int(median(primerange(n**2, (n+1)**2)))
%o A349791 print([a(n) for n in range(2, 52)]) # _Michael S. Branicky_, Dec 05 2021
%o A349791 (Python)
%o A349791 from sympy import primepi, prime
%o A349791 def A349791(n):
%o A349791     b = primepi(n**2)+primepi((n+1)**2)+1
%o A349791     return (prime(b//2)+prime((b+1)//2))//2 if b % 2 else prime(b//2) # _Chai Wah Wu_, Dec 05 2021
%Y A349791 Cf. A000290, A000720, A014085, A309359, A349792.
%K A349791 nonn
%O A349791 2,1
%A A349791 _Hugo Pfoertner_, Dec 05 2021