OFFSET
1,1
COMMENTS
Let {b(n)} be the sequence of perfect powers (A001597); then a(n) = min { b(n)-b(n-1), b(n+1)-b(n) }.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
FORMULA
a(n) = min A053289({n, n-1}\{0}), where A053289(n) = A001597(n+1) - A001597(n). - M. F. Hasler, May 08 2018
EXAMPLE
The perfect powers are 1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, etc. The 7th is 27. This is 2 larger than the 6th (25) and 5 smaller than the 8th (32). So a(7)=2.
MATHEMATICA
pp = {-2, 1}; Do[ If[ !PrimeQ[n] && Apply[GCD, Last[ Transpose[ FactorInteger[n]]]] > 1, pp = Append[pp, n]], {n, 2, 10^4}]; Table[ Min[pp[[n + 1]] - pp[[n]], pp[[n + 2]] - pp[[n + 1]]], {n, 1, 75}]
perfPQ[n_]:=GCD@@FactorInteger[n][[All, 2]]>1; Join[{3, 3}, Min[ Differences[ #]]&/@Partition[Select[Range[5000], perfPQ], 3, 1]] (* Harvey P. Dale, May 04 2021 *)
PROG
(PARI) for(n=L=3+P=-2, 99, ispower(n)&&print1(min(-P+P=L, -L+L=n)", ")) \\ Note: ispower(1)=0. - M. F. Hasler, May 08 2018
(Python)
from sympy import mobius, integer_nthroot
def A075772(n):
if n == 1: return 3
def f(x): return int(n-2+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, n-1, n-1)
b = bisection(lambda x:f(x)+1, a, a)
return min(b-a, bisection(lambda x:f(x)+2, b, b)-b) # Chai Wah Wu, Sep 09 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Neil Fernandez, Oct 09 2002
EXTENSIONS
More terms from Robert G. Wilson v and John W. Layman, Oct 10 2002
STATUS
approved