login
A061670
Distance to nearest prime power p^k, k=0 and k >= 2 (A025475).
5
0, 1, 1, 0, 1, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
OFFSET
1,6
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
There are four different sequences which may legitimately be called "prime powers": A000961 (p^k, k >= 0), A246655 (p^k, k >= 1), A246547 (p^k, k >= 2), A025475 (p^k, k=0 and k >= 2).
Sequence in context: A128519 A303979 A301573 * A236412 A236263 A337126
KEYWORD
nonn,look
AUTHOR
Michel ten Voorde, Jun 16 2001
EXTENSIONS
Definition corrected, and more terms from Robert Israel, Mar 23 2018
STATUS
approved