A051700 Distance from n to closest prime that is different from n.
2, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 3, 2, 1, 6, 1, 2, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 4, 1, 2, 3, 2, 1, 6, 1, 2, 3, 4, 3, 2, 1, 4, 1, 2, 1, 2, 1, 2, 1
Offset: 0
Examples
Closest primes to 0,1,2,3,4 are 2,2,3,2,3.
Links
- T. D. Noe, Table of n, a(n) for n = 0..10000
Crossrefs
Programs
-
Maple
with(numtheory); f := n->min(nextprime(n)-n, n-prevprime(n));
-
Mathematica
Table[Min[NextPrime[n]-n,n-NextPrime[n,-1]],{n,0,200}] (* Harvey P. Dale, Mar 27 2011 *)
Extensions
More terms from James Sellers