A059790 Distance between 2*(n-th prime) and nearest prime.
1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 3, 3, 1, 5, 5, 3, 3, 3, 1, 1, 1, 1, 3, 5, 3, 5, 1, 3, 1, 3, 1, 5, 5, 1, 5, 3, 1, 1, 3, 1, 3, 3, 1, 1, 3, 3, 1, 1, 1, 3, 1, 5, 3, 3, 1, 3, 1, 3, 1, 1, 3, 5, 3, 1, 1, 3, 3, 3, 1, 1, 3, 1, 3, 5, 3, 5, 3, 1, 3, 1, 3, 1, 1, 9, 3, 3, 3, 3, 5, 3, 1, 1, 3, 1, 3, 3, 5, 1, 3, 3, 9, 9
Offset: 1
Keywords
Examples
Distance 1 means that either 2p+1 or 2p-1 is also prime.
Links
- Amiram Eldar, Table of n, a(n) for n = 1..10000
Programs
-
Maple
with(numtheory): [seq(min(2*ithprime(k)-prevprime(2*ithprime(k)), nextprime(2*ithprime(k))-2*ithprime(k)),k=1..256)];
-
Mathematica
a[n_] := Min@ Differences[{NextPrime[#, -1], #, NextPrime[#]} & @ (2*Prime[n])]; Array[a, 100] (* Amiram Eldar, Feb 08 2025 *)
-
PARI
a(n) = {my(m = 2*prime(n)); min(m - precprime(m-1), nextprime(m+1) - m);} \\ Amiram Eldar, Feb 08 2025
Extensions
Offset corrected by Amiram Eldar, Feb 08 2025