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.

A045711 Primes with first digit 5.

Original entry on oeis.org

5, 53, 59, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261
Offset: 1

Views

Author

Keywords

Comments

Subsequence of A000040.

Crossrefs

Column k=5 of A262369.
For primes with initial digit d (1 <= d <= 9) see A045707, A045708, A045709, A045710, A045711, A045712, A045713, A045714, A045715; A073517, A073516, A073515, A073514, A073513, A073512, A073511, A073510, A073509.

Programs

  • Magma
    [p: p in PrimesUpTo(5300) | Intseq(p)[#Intseq(p)] eq 5]; // Vincenzo Librandi, Aug 08 2014
    
  • Mathematica
    Select[Table[Prime[n], {n, 5300}], First[IntegerDigits[#]]==5 &] (* Vincenzo Librandi, Aug 08 2014 *)
  • Python
    from itertools import chain, count, islice
    from sympy import primerange
    def A045711_gen(): # generator of terms
        return chain.from_iterable(primerange(5*(m:=10**l),6*m) for l in count(0))
    A045711_list = list(islice(A045711_gen(),40)) # Chai Wah Wu, Dec 08 2024
    
  • Python
    from sympy import primepi
    def A045711(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return n+x+primepi(min(5*(m:=10**(l:=len(str(x))-1))-1,x))-primepi(min(6*m-1,x))+sum(primepi(5*(m:=10**i)-1)-primepi(6*m-1) for i in range(l))
        return bisection(f,n,n) # Chai Wah Wu, Dec 08 2024

Extensions

More terms from Erich Friedman.
Leading 5 added by Jaroslav Krizek, Apr 29 2010