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

%I #57 Nov 29 2023 13:49:57

%S 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,

%T 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,

%U 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

%N Difference between n and the next prime greater than n.

%C Alternatively, a(n) is the smallest positive k such that n + k is prime. - _N. J. A. Sloane_, Nov 18 2015

%C 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

%C 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

%C 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

%H Vincenzo Librandi, <a href="/A013632/b013632.txt">Table of n, a(n) for n = 0..5000</a>

%H Brăduţ Apostol, Laurenţiu Panaitopol, Lucian Petrescu, and László Tóth, <a href="http://arxiv.org/abs/1503.01086">Some properties of a sequence defined with the aid of prime numbers</a>, arXiv:1503.01086 [math.NT], 2015.

%H Brăduţ Apostol, Laurenţiu Panaitopol, Lucian Petrescu, and László Tóth, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Toth/toth21.html">Some Properties of a Sequence Defined with the Aid of Prime Numbers</a>, J. Int. Seq. 18 (2015) # 15.5.5.

%F a(n) = Prime(1 + PrimePi(n)) - n = A084695(n, 1) (for n > 0). - _G. C. Greubel_, May 12 2023

%e a(30) = 1 because 31 is the next prime greater than 30 and 31 - 30 = 1.

%e a(31) = 6 because 37 is the next prime greater than 31 and 37 - 31 = 6.

%p [ seq(nextprime(i)-i,i=0..100) ];

%t Array[NextPrime[#] - # &, 105, 0] (* _Robert G. Wilson v_, Nov 05 2010 *)

%o (PARI) a(n) = nextprime(n+1) - n; \\ _Michel Marcus_, Mar 04 2015

%o (Magma) [NextPrime(n) - n: n in [0..100]]; // _Vincenzo Librandi_, Dec 27 2018

%o (SageMath) [next_prime(n) - n for n in range(121)] # _G. C. Greubel_, May 12 2023

%Y Cf. A007918, A007920, A084695, A151800.

%K nonn,easy

%O 0,1

%A _N. J. A. Sloane_

%E Incorrect comment removed by _Charles R Greathouse IV_, Mar 18 2010

%E More terms from _Robert G. Wilson v_, Nov 05 2010

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 April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)