login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A301630
a(n) = distance of n-th prime to nearest prime power p^k, k=0 and k >= 2 (A025475).
1
1, 1, 1, 1, 2, 3, 1, 3, 2, 2, 1, 5, 8, 6, 2, 4, 5, 3, 3, 7, 8, 2, 2, 8, 16, 20, 18, 14, 12, 8, 1, 3, 9, 11, 20, 18, 12, 6, 2, 4, 10, 12, 22, 24, 28, 30, 32, 20, 16, 14, 10, 4, 2, 5, 1, 7, 13, 15, 12, 8, 6, 4, 18, 22, 24, 26, 12, 6, 4, 6, 8, 2, 6, 12, 18, 22, 28, 36, 40, 48, 58, 60, 70, 72, 73, 69, 63, 55
OFFSET
1,5
FORMULA
a(n) = A061670(A000040(n)).
EXAMPLE
a(9) = a(10) = 2 because 5^2 is the nearest prime power (A025475) to prime(9) = 23 and 3^3 is the nearest prime power (A025475) to prime(10) = 29.
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
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: A325520 A072457 A364554 * A063047 A003270 A099054
KEYWORD
nonn,look
AUTHOR
Altug Alkan, Mar 24 2018
STATUS
approved