OFFSET
1,1
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..5000
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))
(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
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
More terms from Erich Friedman.
STATUS
approved