OFFSET
1,5
MAPLE
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:
seq(A078685(n), n=1..80) ; # R. J. Mathar, Apr 08 2011
PROG
(Sage)
def A078685(n):
p = nth_prime(n)
x0 = floor(log(p, 2))
return min(abs(p-2**x) for x in (x0, x0+1))
# D. S. McNeil, Apr 08 2011
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Dec 17 2002
STATUS
approved