login
Let f(n) = 2n-7. Difference between f(n) and the nearest prime < f(n).
1

%I #13 Oct 18 2019 03:59:08

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

%T 2,4,2,4,6,2,4,6,8,2,4,2,2,4,2,2,4,2,4,6,8,10,12,14,2,4,2,4,6,2,2,4,6,

%U 8,10,2,2,4,6,2,4,6,2,4,2,4,6,2,4,6,2,2

%N Let f(n) = 2n-7. Difference between f(n) and the nearest prime < f(n).

%C It's known that there is always a prime between n and 2n - 7 for all n >= 10.

%H Michel Lagneau, <a href="/A212595/b212595.txt">Table of n, a(n) for n = 10..10000</a>

%H Peter Vandendriessche and Hojoo Lee, <a href="http://www.scribd.com/doc/24487088/Hojoo-Lee-Peter-Vandendriessche-Problems-in-Elementary-Number-Theory">Problems in elementary number theory</a>, Problem E37

%e a(12) = 4 because 2*12-7 = 17, and the nearest prime p < 17 such that 12 < p < 17 is p = 13. Hence a(12) = 17 - 13 = 4.

%p with(numtheory):for n from 10 to 100 do:x:=2*n-7:i:=0:for p from x-1 by -1 to n+1 while(i=0) do:if type(p,prime)=true then i:=1:printf(`%d, `,x-p):else fi:od:od:

%t Array[# - Prime@ PrimePi[# - 1] &[2 # - 7] &, 86, 10] (* _Michael De Vlieger_, Oct 17 2019 *)

%K nonn

%O 10,1

%A _Michel Lagneau_, May 22 2012