Given a prime number p
, is there always a smaller positive integer exponent k
such that p+2^k
is also prime? We will call the smallest possible value of this exponent the k*.
We could interpret this number k
as the position where we could add 1 to the binary expression of p
in order to obtain another prime number, the smallest possible one.
For example, 61+2^8 = 317
. The prime number 61 has a binary expression of 111101 and its "binary distance" function is equal to 8 (dyb[61]=8)
. This means that in the 8th position of its binary expression, we need to add a 1 (considering the first position as 0, so we have positions from 0 to 5 in 111101): 100111101, which is equal to the prime number 317.
31+2^4 = 47 dyb[31]=4
, since 31 in base 2 is 11111, and 47 in base 2 is 101111.
I made the following implementation:
dyb[n_] := Module[{c = 0, p = 0, i = 1},
If[n > 2 && PrimeQ[n],
While[! PrimeQ[n + 2^i], i = i + 1; p = i; c = p; ]; c ]]
Print[dyb[61]]
I would like to obtain a table with a certain quantity of primes, with the first column containing the primes p
, the second column containing the binary distance k
, and the third column containing the second prime q
.
Prime p ----- Binary distance ----- Prime q 61 8 317