OFFSET
1,5
LINKS
Altug Alkan, Table of n, a(n) for n = 1..10000
EXAMPLE
MAPLE
Primes:= select(isprime, [2, seq(i, i=3..1000, 2)]):
Ppows:= sort([1, seq(seq(p^j, j=2..floor(log[p](1000))), p=Primes)]):
for n from 1 while Primes[n] < Ppows[-1] do
i:= ListTools:-BinaryPlace(Ppows, Primes[n]);
A[n]:= min(Primes[n]-Ppows[i], Ppows[i+1]-Primes[n])
od:
seq(A[i], i=1..n-1); # Robert Israel, Mar 26 2018
PROG
(PARI) isA025475(n) = {isprimepower(n) && !isprime(n) || n==1}
a(n) = {my(k=1, p=prime(n)); while(!isA025475(p+k) && !isA025475(p-k), k++); k; }
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Altug Alkan, Mar 24 2018
STATUS
approved