OFFSET
1,6
LINKS
EXAMPLE
a(12)=3 because 9=3^2 is the nearest power to 12 (12-9=3).
MAPLE
N:= 1000: # to get a(1)..a(M) where M is the greatest prime power <= N.
Primes:= select(isprime, [2, seq(i, i=3..floor(sqrt(N)))]):
Pows:= sort(convert({1, seq(seq(p^e, e=2..floor(log[p](N))), p=Primes)}, list)):
nP:= nops(Pows):
M:= Pows[nP]:
V:= Vector(M):
V[2]:= 1:
for i from 2 to nP-1 do
for x from ceil((Pows[i]+Pows[i-1])/2) to floor((Pows[i]+Pows[i+1])/2) do
V[x]:= abs(x - Pows[i])
od od:
for x from ceil((M+Pows[nP-1])/2) to M do V[x]:= M - x od:
convert(V, list); # Robert Israel, Mar 23 2018
PROG
(PARI) isA025475(n) = {isprimepower(n) && !isprime(n) || n==1}
a(n) = {my(k=0); while(!isA025475(n+k) && !isA025475(n-k), k++); k; } \\ Altug Alkan, Mar 23 2018
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Michel ten Voorde, Jun 16 2001
EXTENSIONS
Definition corrected, and more terms from Robert Israel, Mar 23 2018
STATUS
approved