login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Difference between (least prime >= n) and (largest prime <= n).
4

%I #14 Sep 23 2018 20:56:57

%S 0,0,2,0,2,0,4,4,4,0,2,0,4,4,4,0,2,0,4,4,4,0,6,6,6,6,6,0,2,0,6,6,6,6,

%T 6,0,4,4,4,0,2,0,4,4,4,0,6,6,6,6,6,0,6,6,6,6,6,0,2,0,6,6,6,6,6,0,4,4,

%U 4,0,2,0,6,6,6,6,6,0,4,4,4,0,6,6,6,6,6,0,8,8,8,8,8,8,8,0,4,4,4,0,2,0,4,4,4

%N Difference between (least prime >= n) and (largest prime <= n).

%C a(n) = 0 iff n is prime.

%H Antti Karttunen, <a href="/A072680/b072680.txt">Table of n, a(n) for n = 2..65537</a>

%F a(n) = A007918(n) - A007917(n).

%F a(n) = A057427(n - A007917(n)) * A001223(A049084(A007917(n))).

%t f[n_]:=If[PrimeQ[n],0,NextPrime[n]-NextPrime[n,-1]];Array[f,110,2] (* _Harvey P. Dale_, Sep 22 2011 *)

%o (MuPAD) numlib::prevprime(i)*(-1)-nextprime(i)*(-1)$ i = 2..106 // _Zerinvary Lajos_, Feb 26 2007

%o (PARI) A072680(n) = (nextprime(n) - precprime(n)); \\ _Antti Karttunen_, Sep 23 2018

%Y Cf. A007917, A007918, A013633, A072681, A097106.

%K nonn

%O 2,3

%A _Reinhard Zumkeller_, Jul 01 2002