login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Minimum value of |prime(n) - 2^x|.
1

%I #16 Mar 08 2020 11:38:17

%S 0,1,1,1,3,3,1,3,7,3,1,5,9,11,15,11,5,3,3,7,9,15,19,25,31,27,25,21,19,

%T 15,1,3,9,11,21,23,29,35,39,45,51,53,63,63,59,57,45,33,29,27,23,17,15,

%U 5,1,7,13,15,21,25,27,37,51,55,57,61,75,81,91,93,97,103,111,117,123,127

%N Minimum value of |prime(n) - 2^x|.

%p A078685 := proc(n) local p,a,x,r ; p := ithprime(n) ; a := p ; for x from 0 do r := p-2^x ; if r < -p then return a ; fi ; r := abs(r) ; if r < a then a := r ; end if; end do: a ; end proc:

%p seq(A078685(n),n=1..80) ; # _R. J. Mathar_, Apr 08 2011

%o (Sage)

%o def A078685(n):

%o p = nth_prime(n)

%o x0 = floor(log(p,2))

%o return min(abs(p-2**x) for x in (x0, x0+1))

%o # _D. S. McNeil_, Apr 08 2011

%K nonn

%O 1,5

%A _Benoit Cloitre_, Dec 17 2002