OFFSET
1,1
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..5000
MATHEMATICA
Select[Table[Prime[n], {n, 4000}], First[IntegerDigits[#]]==3 &] (* Vincenzo Librandi, Aug 08 2014 *)
PROG
(PARI) isok(n) = isprime(n) && (digits(n, 10)[1] == 3) \\ Michel Marcus, Jun 08 2013
(Magma) [p: p in PrimesUpTo(3300) | Intseq(p)[#Intseq(p)] eq 3]; // Vincenzo Librandi, Aug 08 2014
(Python)
from itertools import chain, count, islice
from sympy import primerange
def A045709_gen(): # generator of terms
return chain.from_iterable(primerange(3*(m:=10**l), m<<2) for l in count(0))
(Python)
from sympy import primepi
def A045709(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(3*(m:=10**(l:=len(str(x))-1))-1, x))-primepi(min((m<<2)-1, x))+sum(primepi(3*(m:=10**i)-1)-primepi((m<<2)-1) for i in range(l))
return bisection(f, n, n) # Chai Wah Wu, Dec 07 2024
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
More terms from Erich Friedman.
STATUS
approved