login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Primes with first digit 2.
24

%I #32 Dec 08 2024 02:36:29

%S 2,23,29,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,

%T 293,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,

%U 2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221

%N Primes with first digit 2.

%H Reinhard Zumkeller, <a href="/A045708/b045708.txt">Table of n, a(n) for n = 1..10000</a>

%F See A045707 for comments on density of these sequences.

%t Select[Table[Prime[n], {n, 3000}], First[IntegerDigits[#]]==2 &] (* _Vincenzo Librandi_, Aug 08 2014 *)

%o (Haskell)

%o a045708 n = a045708_list !! (n-1)

%o a045708_list = filter ((== 2) . a000030) a000040_list

%o -- _Reinhard Zumkeller_, Mar 16 2012

%o (Magma) [p: p in PrimesUpTo(2300) | Intseq(p)[#Intseq(p)] eq 2]; // _Vincenzo Librandi_, Aug 08 2014

%o (Python)

%o from sympy import isprime

%o def agen(limit=float('inf')):

%o yield 2

%o digits, adder = 1, 20

%o while True:

%o for i in range(1, 10**digits, 2):

%o test = adder + i

%o if test > limit: return

%o if isprime(test): yield test

%o digits, adder = digits+1, adder*10

%o agento = lambda lim: agen(limit=lim)

%o print(list(agento(2222))) # _Michael S. Branicky_, Feb 23 2021

%o (Python)

%o from sympy import primepi

%o def A045708(n):

%o def bisection(f,kmin=0,kmax=1):

%o while f(kmax) > kmax: kmax <<= 1

%o while kmax-kmin > 1:

%o kmid = kmax+kmin>>1

%o if f(kmid) <= kmid:

%o kmax = kmid

%o else:

%o kmin = kmid

%o return kmax

%o 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 return bisection(f,n,n) # _Chai Wah Wu_, Dec 07 2024

%Y Cf. A000040.

%Y 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 Cf. A000030, subsequence of A208272.

%Y Column k=2 of A262369.

%K nonn,base,easy,changed

%O 1,1

%A _Felice Russo_

%E More terms from _Erich Friedman_.

%E Offset fixed by _Reinhard Zumkeller_, Mar 15 2012