Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A045710
Primes with first digit 4.
23
41, 43, 47, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211
OFFSET
1,1
LINKS
MATHEMATICA
Select[Table[Prime[n], {n, 1000}], First[IntegerDigits[#]] == 4 &]
Flatten[Table[Prime[Range[PrimePi[4 * 10^n] + 1, PrimePi[5 * 10^n]]], {n, 3}]] (* Alonso del Arte, Jul 19 2014 *)
PROG
(Magma) [p: p in PrimesUpTo(10^4) | Intseq(p)[#Intseq(p)] eq 4]; // Bruno Berselli, Jul 19 2014
(Python)
from itertools import chain, count, islice
from sympy import primerange
def A045710_gen(): # generator of terms
return chain.from_iterable(primerange((m:=10**l)<<2, 5*m) for l in count(0))
A045710_list = list(islice(A045710_gen(), 40)) # Chai Wah Wu, Dec 08 2024
(Python)
from sympy import primepi
def A045710(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))<<2)-1, x))-primepi(min(5*m-1, x))+sum(primepi(((m:=10**i)<<2)-1)-primepi(5*m-1) for i in range(l))
return bisection(f, n, n) # Chai Wah Wu, Dec 08 2024
CROSSREFS
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.
Column k=4 of A262369.
Sequence in context: A345346 A062669 A284290 * A090152 A139774 A007643
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
More terms from Erich Friedman.
STATUS
approved