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.

This page as a plain text file.
%I A045708 #32 Dec 08 2024 02:36:29
%S A045708 2,23,29,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,
%T A045708 293,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,
%U A045708 2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221
%N A045708 Primes with first digit 2.
%H A045708 Reinhard Zumkeller, <a href="/A045708/b045708.txt">Table of n, a(n) for n = 1..10000</a>
%F A045708 See A045707 for comments on density of these sequences.
%t A045708 Select[Table[Prime[n], {n, 3000}], First[IntegerDigits[#]]==2 &] (* _Vincenzo Librandi_, Aug 08 2014 *)
%o A045708 (Haskell)
%o A045708 a045708 n = a045708_list !! (n-1)
%o A045708 a045708_list = filter ((== 2) . a000030) a000040_list
%o A045708 -- _Reinhard Zumkeller_, Mar 16 2012
%o A045708 (Magma) [p: p in PrimesUpTo(2300) | Intseq(p)[#Intseq(p)] eq 2]; // _Vincenzo Librandi_, Aug 08 2014
%o A045708 (Python)
%o A045708 from sympy import isprime
%o A045708 def agen(limit=float('inf')):
%o A045708   yield 2
%o A045708   digits, adder = 1, 20
%o A045708   while True:
%o A045708     for i in range(1, 10**digits, 2):
%o A045708       test = adder + i
%o A045708       if test > limit: return
%o A045708       if isprime(test): yield test
%o A045708     digits, adder = digits+1, adder*10
%o A045708 agento = lambda lim: agen(limit=lim)
%o A045708 print(list(agento(2222))) # _Michael S. Branicky_, Feb 23 2021
%o A045708 (Python)
%o A045708 from sympy import primepi
%o A045708 def A045708(n):
%o A045708     def bisection(f,kmin=0,kmax=1):
%o A045708         while f(kmax) > kmax: kmax <<= 1
%o A045708         while kmax-kmin > 1:
%o A045708             kmid = kmax+kmin>>1
%o A045708             if f(kmid) <= kmid:
%o A045708                 kmax = kmid
%o A045708             else:
%o A045708                 kmin = kmid
%o A045708         return kmax
%o A045708     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))
%o A045708     return bisection(f,n,n) # _Chai Wah Wu_, Dec 07 2024
%Y A045708 Cf. A000040.
%Y A045708 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
%Y A045708 Cf. A000030, subsequence of A208272.
%Y A045708 Column k=2 of A262369.
%K A045708 nonn,base,easy
%O A045708 1,1
%A A045708 _Felice Russo_
%E A045708 More terms from _Erich Friedman_.
%E A045708 Offset fixed by _Reinhard Zumkeller_, Mar 15 2012