OFFSET
1,1
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..22
EXAMPLE
The two closest perfect powers to 25 are 27 (difference = 2) and 32 (difference = 7). The third closest is 16 (difference = 9). Both 27 and 32 are greater than 25, so 25 is in the list.
PROG
(Python)
from itertools import count, islice
from sympy import mobius, integer_nthroot
def A076433_gen(): # generator of terms
def f(x): return int(x+sum(mobius(k)*(integer_nthroot(x, k)[0]-1) for k in range(2, x.bit_length())))
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
a = bisection(f)
b = bisection(lambda x:f(x)+1, a, a)
c = bisection(lambda x:f(x)+2, b, b)
for i in count(3):
d = bisection(lambda x:f(x)+i, c, c)
if b-a > d-b:
yield b
a, b, c=b, c, d
CROSSREFS
KEYWORD
nonn
AUTHOR
Neil Fernandez, Oct 10 2002
EXTENSIONS
More terms from Jud McCranie and Robert G. Wilson v, Oct 11 2002
a(6)-a(17) from Donovan Johnson, Sep 03 2008
STATUS
approved