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.

A045708 Primes with first digit 2.

Original entry on oeis.org

2, 23, 29, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A000040.
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
Cf. A000030, subsequence of A208272.
Column k=2 of A262369.

Programs

  • Haskell
    a045708 n = a045708_list !! (n-1)
    a045708_list = filter ((== 2) . a000030) a000040_list
    -- Reinhard Zumkeller, Mar 16 2012
    
  • Magma
    [p: p in PrimesUpTo(2300) | Intseq(p)[#Intseq(p)] eq 2]; // Vincenzo Librandi, Aug 08 2014
    
  • Mathematica
    Select[Table[Prime[n], {n, 3000}], First[IntegerDigits[#]]==2 &] (* Vincenzo Librandi, Aug 08 2014 *)
  • Python
    from sympy import isprime
    def agen(limit=float('inf')):
      yield 2
      digits, adder = 1, 20
      while True:
        for i in range(1, 10**digits, 2):
          test = adder + i
          if test > limit: return
          if isprime(test): yield test
        digits, adder = digits+1, adder*10
    agento = lambda lim: agen(limit=lim)
    print(list(agento(2222))) # Michael S. Branicky, Feb 23 2021
    
  • Python
    from sympy import primepi
    def A045708(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(((m:=10**(l:=len(str(x))-1))<<1)-1,x))-primepi(min(3*m-1,x))+sum(primepi(((m:=10**i)<<1)-1)-primepi(3*m-1) for i in range(l))
        return bisection(f,n,n) # Chai Wah Wu, Dec 07 2024

Formula

See A045707 for comments on density of these sequences.

Extensions

More terms from Erich Friedman.
Offset fixed by Reinhard Zumkeller, Mar 15 2012