login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A301630 a(n) = distance of n-th prime to nearest prime power p^k, k=0 and k >= 2 (A025475). 1

%I #23 Mar 26 2018 20:58:52

%S 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,

%T 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,

%U 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

%N a(n) = distance of n-th prime to nearest prime power p^k, k=0 and k >= 2 (A025475).

%H Altug Alkan, <a href="/A301630/b301630.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A061670(A000040(n)).

%e 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.

%p Primes:= select(isprime, [2,seq(i,i=3..1000,2)]):

%p Ppows:= sort([1,seq(seq(p^j, j=2..floor(log[p](1000))),p=Primes)]):

%p for n from 1 while Primes[n] < Ppows[-1] do

%p i:= ListTools:-BinaryPlace(Ppows,Primes[n]);

%p A[n]:= min(Primes[n]-Ppows[i],Ppows[i+1]-Primes[n])

%p od:

%p seq(A[i],i=1..n-1); # _Robert Israel_, Mar 26 2018

%o (PARI) isA025475(n) = {isprimepower(n) && !isprime(n) || n==1}

%o a(n) = {my(k=1, p=prime(n)); while(!isA025475(p+k) && !isA025475(p-k), k++); k; }

%Y Cf. A047972, A047973, A061670.

%Y 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).

%K nonn,look

%O 1,5

%A _Altug Alkan_, Mar 24 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)