I'm new to Mathematica so my question might be trivial.
How do I generate a $200-bit$ prime with the condition that the 10 most significant bits in its binary representation are equal to some binary string (for example $1001110011$)?
I know that I can use RandomPrime[{2^199, 2^200 - 1}]
to generate primes in the required range, but how do I guarantee the previous condition?
NextPrime
. (1) Set your initial bits. (2) Pick a random integerrand
between the lowest and highest values that have those initial bits. (3) TakeNextPrime[rand]
. (4) If it exceeds the max, rinse and repeat. $\endgroup$ – Daniel Lichtblau Jan 24 '18 at 17:59