A105161 Difference between n and the second-smallest prime larger than n.
3, 2, 3, 4, 3, 6, 5, 6, 5, 4, 3, 6, 5, 6, 5, 4, 3, 6, 5, 10, 9, 8, 7, 8, 7, 6, 5, 4, 3, 8, 7, 10, 9, 8, 7, 6, 5, 6, 5, 4, 3, 6, 5, 10, 9, 8, 7, 12, 11, 10, 9, 8, 7, 8, 7, 6, 5, 4, 3, 8, 7, 10, 9, 8, 7, 6, 5, 6, 5, 4, 3, 8, 7, 10, 9, 8, 7, 6, 5, 10, 9, 8, 7, 14, 13, 12, 11, 10, 9, 12, 11, 10, 9, 8, 7, 6, 5
Offset: 0
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 0..10000
Crossrefs
Cf. A101300.
Programs
-
Maple
with(numtheory); A105161:=n->ithprime(pi(n) + 2); seq(A105161(n), n=0..100); # Wesley Ivan Hurt, Feb 26 2014
-
Mathematica
Table[Prime[PrimePi[n] + 2], {n, 0, 100}] (* Wesley Ivan Hurt, Feb 26 2014 *)
-
PARI
a(n) = prime(primepi(n)+2) - n; \\ Michel Marcus, Oct 09 2013
-
PARI
a(n)=nextprime(nextprime(n+1)+1)-n \\ Charles R Greathouse IV, Oct 09 2013
-
Python
from sympy import nextprime def a(n): return nextprime(nextprime(n)) - n print([a(n) for n in range(97)]) # Michael S. Branicky, Mar 02 2021
Formula
a(n) = prime(pi(n)+2) - n.