A013632 Difference between n and the next prime greater than n.
2, 1, 1, 2, 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, 3
Offset: 0
Examples
a(30) = 1 because 31 is the next prime greater than 30 and 31 - 30 = 1. a(31) = 6 because 37 is the next prime greater than 31 and 37 - 31 = 6.
Links
- Vincenzo Librandi, Table of n, a(n) for n = 0..5000
- Brăduţ Apostol, Laurenţiu Panaitopol, Lucian Petrescu, and László Tóth, Some properties of a sequence defined with the aid of prime numbers, arXiv:1503.01086 [math.NT], 2015.
- Brăduţ Apostol, Laurenţiu Panaitopol, Lucian Petrescu, and László Tóth, Some Properties of a Sequence Defined with the Aid of Prime Numbers, J. Int. Seq. 18 (2015) # 15.5.5.
Programs
-
Magma
[NextPrime(n) - n: n in [0..100]]; // Vincenzo Librandi, Dec 27 2018
-
Maple
[ seq(nextprime(i)-i,i=0..100) ];
-
Mathematica
Array[NextPrime[#] - # &, 105, 0] (* Robert G. Wilson v, Nov 05 2010 *)
-
PARI
a(n) = nextprime(n+1) - n; \\ Michel Marcus, Mar 04 2015
-
SageMath
[next_prime(n) - n for n in range(121)] # G. C. Greubel, May 12 2023
Formula
a(n) = Prime(1 + PrimePi(n)) - n = A084695(n, 1) (for n > 0). - G. C. Greubel, May 12 2023
Extensions
Incorrect comment removed by Charles R Greathouse IV, Mar 18 2010
More terms from Robert G. Wilson v, Nov 05 2010
Comments