Jump to content

Miller–Rabin primality test: Difference between revisions

Line 869:
 
=={{header|Mathematica}}==
<lang Mathematica>MillerRabin[n_,x1_k_]:=Module[{d=n-1,s=0,test=True},While[Mod[d,2]==0 ,d/=2 ;s++]
Do[
a=RandomInteger[{2,n-1}]; x=Mod[Power[a,d] ,n];
Line 876:
If[ x != n-1, test=False ];
];
,{x1k}];
Print[test] ]
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.