OFFSET
1,2
COMMENTS
Also, number of distinct primes among the first n prime powers (cf. A246655).
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000
EXAMPLE
The 4th prime, 7, is followed by prime powers 8 and 9 before the next prime (11), accounting for three consecutive 4s in the sequence (at indices n = 5..7). Similarly, the three 9s (at n = 13..15) show that the 9th prime (23) is followed by two prime powers (25, 27) before the next prime (29). This occurs again at n = 40..42 (a(n) = 30), 358..360 (a(n) = 327) and 3588..3590 (a(n) = 3512). - M. F. Hasler, Oct 31 2024
MATHEMATICA
A362965list[upto_]:=PrimePi[Select[Range[upto], PrimePowerQ]]; A362965list[500] (* Paolo Xausa, Jun 29 2023 *)
PROG
(PARI) apply(primepi, [p| p <- [1..300], isprimepower(p)]) \\ Michel Marcus, Jun 04 2023
(Python)
from sympy import primepi, integer_nthroot
def A362965(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 int(n+x-sum(primepi(integer_nthroot(x, k)[0]) for k in range(1, x.bit_length())))
return int(primepi(bisection(f, n, n))) # Chai Wah Wu, Oct 28 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Max Alekseyev, Jun 03 2023
STATUS
approved