The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A013632 Difference between n and the next prime greater than n. 43
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,1
COMMENTS
Alternatively, a(n) is the smallest positive k such that n + k is prime. - N. J. A. Sloane, Nov 18 2015
Except for a(0) and a(1), a(n) is the least k such that gcd(n!, n + k) = 1. - Robert G. Wilson v, Nov 05 2010
This sequence uses the "strictly larger" variant A151800 of the nextprime function, rather than A007918. Therefore all terms are positive and a(n) = 1 if and only if n + 1 is a prime. - M. F. Hasler, Sep 09 2015
For n > 0, a(n) and n are of opposite parity. Also, by Bertrand's postulate (actually a theorem), for n > 1, a(n) < n. - Zak Seidov, Dec 27 2018
LINKS
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.
FORMULA
a(n) = Prime(1 + PrimePi(n)) - n = A084695(n, 1) (for n > 0). - G. C. Greubel, May 12 2023
EXAMPLE
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.
MAPLE
[ seq(nextprime(i)-i, i=0..100) ];
MATHEMATICA
Array[NextPrime[#] - # &, 105, 0] (* Robert G. Wilson v, Nov 05 2010 *)
PROG
(PARI) a(n) = nextprime(n+1) - n; \\ Michel Marcus, Mar 04 2015
(Magma) [NextPrime(n) - n: n in [0..100]]; // Vincenzo Librandi, Dec 27 2018
(SageMath) [next_prime(n) - n for n in range(121)] # G. C. Greubel, May 12 2023
CROSSREFS
Sequence in context: A131374 A360286 A207409 * A080121 A122901 A001917
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
Incorrect comment removed by Charles R Greathouse IV, Mar 18 2010
More terms from Robert G. Wilson v, Nov 05 2010
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 18 15:50 EDT 2024. Contains 372664 sequences. (Running on oeis4.)