OFFSET
1,2
MATHEMATICA
perpowQ[n_]:=n==1||GCD@@FactorInteger[n][[All, 2]]>1;
Table[NestWhile[#+1&, n, #>1&&!perpowQ[#]&], {n, 100}]
PROG
(Python)
from sympy import mobius, integer_nthroot
def A377468(n):
if n == 1: return 1
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(x-1+sum(mobius(k)*(integer_nthroot(x, k)[0]-1) for k in range(2, x.bit_length())))
m = n-f(n-1)
return bisection(lambda x:f(x)+m, n-1, n) # Chai Wah Wu, Nov 05 2024
CROSSREFS
The version for prime-powers is A000015.
Positions of last appearances are also A001597.
The version for squarefree numbers is A067535.
Run-lengths are A076412.
The opposite version (greatest perfect-power <= n) is A081676.
A069623 counts perfect-powers <= n.
A076411 counts perfect-powers < n.
A131605 lists perfect-powers that are not prime-powers.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Nov 05 2024
STATUS
approved