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.

Showing 1-3 of 3 results.

A309329 Median of primes with n decimal digits.

Original entry on oeis.org

4, 47, 509, 5273, 53047, 532887, 5356259, 53765483, 539119753, 5402600081, 54118210435, 541947386821, 5425907665571, 54313871643797, 543611236251491, 5440228524355329, 54438462600610510, 544705097744731559, 5449909581264135103
Offset: 1

Views

Author

Hugo Pfoertner, Jul 25 2019

Keywords

Comments

The number of n-digit primes < a(n) equals the number of n-digit primes > a(n). The median of an even number of values is understood to be defined as the arithmetic mean of the two central elements.

Examples

			a(1) = 4 because {2, 3, 5, 7} are the 4 one-digit primes. The 2 central elements of the sorted list are 3 and 5. 4 = (3 + 5)/2.
a(2) = 47 because it is the central element of the sorted list of the A006879(2) = 21 two-digit primes. There are 10 such primes < 47 and 10 such primes > 47.
		

Crossrefs

Formula

a(n) = (prime(A006880(n-1) + ceiling(A006879(n)/2)) + prime(A006880(n-1) + floor(A006879(n)/2) + 1)) / 2.

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

Original entry on oeis.org

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
Offset: 2

Views

Author

Hugo Pfoertner, Dec 05 2021

Keywords

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.

Crossrefs

Programs

  • Mathematica
    Table[Median@Select[Range[n^2,(n+1)^2],PrimeQ],{n,2,51}] (* Giorgos Kalogeropoulos, Dec 05 2021 *)
  • 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

A328032 If there are m primes between 10^(n-1) and 10^n, a(n) is the middle prime if m is odd, otherwise the larger of the two middle primes.

Original entry on oeis.org

5, 47, 509, 5273, 53047, 532907, 5356259, 53765519, 539119753, 5402600081, 54118210441, 541947386821, 5425907665571, 54313871643797, 543611236251491, 5440228524355381, 54438462600610513, 544705097744731559, 5449909581264135103
Offset: 1

Views

Author

Robert G. Wilson v, Oct 02 2019

Keywords

Comments

This sequence, unlike A309329, only contains primes.
For n > 2, a(n) > 10*a(n-1) for the terms shown. Does this continue?
The prime index of a(n): 3, 15, 97, 699, 5411, 44046, 371539, 3213018, 28304495, 252950023, 2286553663, 20862983416, 191836724429, 1775503643821, 16524756086736, 154541455728298, 1451397749344080, 13681755722697547, 129398810782042734, 1227438634918631724, 11674044544289825385, 111297278087667319110, 1063393839148059937607, 10180460079478002418395, 97640954583246485139774, 938046530135790455369642, 9025853588857058793877502, ..., .

Examples

			a(1) is 5 since, among the single-digit primes, i.e., {2, 3, 5, 7}, the two middle primes are {3, 5}, of which the larger one is 5;
a(2) is 47 since it is the middle prime of the two-digit primes, i.e., {11, 13, 17, ..., 47, ..., 83, 89, 97};
a(3) is 509 since it is the middle prime of the three-digit primes, i.e., {101, 103, 107, ..., 509, ..., 983, 991, 997}.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{p = PrimePi[ 10^(n -1)], q = PrimePi[ 10^n]}, Prime[ Ceiling[(q +p +1)/2]]]; Array[f, 13]

Formula

a(n) is the next prime after A309329(n) - 1.
Showing 1-3 of 3 results.