Building on the same context of this question

Is it possible to enforce constraints on the properties of the generated prime? For example, I'm trying to find a prime $p$ in the range specified in the question on top with the property that $5 \in QR_p$ which mean that there exists a number $x$ such that $x^2 \equiv 5\pmod p$

  • $\begingroup$ I'd generate a number of primes, and then test each. $\endgroup$ – David G. Stork Jan 24 '18 at 20:03
  • $\begingroup$ could you at least put your criteria in mathematica form? $\endgroup$ – george2079 Jan 24 '18 at 20:30

How about

randprime[] := RandomPrime[{BitShiftLeft[2^^1001110011, 190], 
  BitShiftLeft[2^^1001110011 + 1, 190] - 1}]

NestWhile[randprime[] &, 0, JacobiSymbol[5, #] != 1 &]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.