This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A051702 #18 Jul 02 2025 16:01:58 %S A051702 1,1,2,2,2,2,2,2,4,2,2,4,2,2,4,6,2,2,4,2,2,4,4,6,4,2,2,2,2,4,4,4,2,2, %T A051702 2,2,6,4,4,6,2,2,2,2,2,2,12,4,2,2,4,2,2,6,6,6,2,2,4,2,2,10,4,2,2,4,6, %U A051702 6,2,2,4,6,6,6,4,4,6,4,4,8,2,2,2,2,4,4,6,4,2,2,4,8,4,4,4,4,6,2,2,6,6,6,6,2 %N A051702 Distance from n-th prime to closest prime. %H A051702 T. D. Noe, <a href="/A051702/b051702.txt">Table of n, a(n) for n = 1..10000</a> %e A051702 Closest primes to 2,3,5,7,11 are 3,2,3,5,13. %t A051702 a[n_] := Min[(p = Prime[n]) - NextPrime[p, -1], NextPrime[p] - p]; Table[a[n], {n, 1, 104}] (* _Jean-François Alcover_, May 27 2013 *) %t A051702 Join[{1},Min[Differences[#]]&/@Partition[Prime[Range[110]],3,1]] (* _Harvey P. Dale_, Sep 23 2016 *) %o A051702 (PARI) a(n,p=prime(n))=min(p-precprime(p-1),nextprime(p+1)-p) \\ _Charles R Greathouse IV_, Feb 06 2017 %Y A051702 Related sequences: A023186-A023188, A046929-A046931, A051650, A051652, A051697-A051702, A051728-A051730. %Y A051702 A046929(n+1) + 1. %K A051702 nonn,easy,nice %O A051702 1,3 %A A051702 _N. J. A. Sloane_ %E A051702 More terms from _James Sellers_