For testing a particular algorithm I found mathematica is the best way as it has all the tools I need. I am stuck in a number theory part and since I am not an expert in mathematica I do not know how to write a code that seemingly involves loops. I want to pick random integers $a,b$ in interval $[T,2T]$ at $T>0$ and obtain $u,v\in\mathbb Z$ such that
$au-bv=1$ (Euclidean algorithm)
$au+bv$ is a prime
$GCD(ab,uv)=1$
$0<u,v<4T$
holds.
Is there simple enough code to do this?
It would help me to have 5. $a,b,u,v$ are all prime integers.
FindInstance[]
function without any loops. $\endgroup$u,v
need not exist. Are you wanting code that will keep picking randoma,b
until you get a pair for which they do exist? $\endgroup$a,b,u,v
sought or just, as it was worded,u and v
? (2) Loops, should you wish to use them explicitly, can be accomplished with any ofFor
,Do
, andWhile
. Same as in other languages. $\endgroup$