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.

A349792 Numbers k such that k*(k+1) is the median of the primes between k^2 and (k+1)^2.

Original entry on oeis.org

2, 3, 5, 6, 8, 25, 29, 38, 59, 101, 135, 217, 260, 295, 317, 455, 551, 686, 687, 720, 825, 912, 1193, 1233, 1300, 1879, 1967, 2200, 2576, 2719, 2857, 3303, 3512, 4215, 4241, 4448, 4658, 5825, 5932, 5952, 6155, 6750, 7275, 10305, 10323, 10962, 11279, 13495, 14104
Offset: 1

Views

Author

Hugo Pfoertner, Dec 05 2021

Keywords

Crossrefs

Programs

  • Mathematica
    Select[Range@3000,Median@Select[Range[#^2,(#+1)^2],PrimeQ]==#(#+1)&] (* Giorgos Kalogeropoulos, Dec 05 2021 *)
  • PARI
    a349791(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,5000, my(t=k*(k+1)); if(t==a349791(k),print1(k,", ")))
    
  • Python
    from sympy import primerange
    from statistics import median
    def ok(n): return n>1 and int(median(primerange(n**2, (n+1)**2)))==n*(n+1)
    print([k for k in range(999) if ok(k)]) # Michael S. Branicky, Dec 05 2021
    
  • Python
    from itertools import count, islice
    from sympy import primepi, prime, nextprime
    def A349792gen(): # generator of terms
        p1 = 0
        for n in count(1):
            p2 = primepi((n+1)**2)
            b = p1 + p2 + 1
            if b % 2:
                p = prime(b//2)
                q = nextprime(p)
                if p+q == 2*n*(n+1):
                    yield n
            p1 = p2
    A349792_list = list(islice(A349792gen(),12)) # Chai Wah Wu, Dec 08 2021