Precomputation: (, with )
Input: (, , ,   )
Output: (, composite or probably prime)
;
;
for     from 1 to    do
;
;
;
if  orthen
continue;
for   fromtodo
;
;
if    then
return ( composite);
;
if    then
continue;
return ( composite);
return ( probably prime)
Algorithm 2: Modified Miller-Rabin Primality Test.