Miller–Rabin primality test: Difference between revisions

Added Wren
m (Phix/mpfr)
(Added Wren)
Line 5,232:
991
997</pre>
 
=={{header|Wren}}==
{{libheader|Wren-big}}
The ''BigInt.isProbablePrime(iterations)'' method in the above module already uses the Miller-Rabin test to check for primality.
 
I've therefore used this method to check the same numbers as in my Kotlin entry.
<lang ecmascript>import "/big" for BigInt
 
var iters = 10
// find all primes < 100
System.print("The following numbers less than 100 are prime:")
System.write("2 ")
for (i in 3..99) {
if (BigInt.new(i).isProbablePrime(iters)) System.write("%(i) ")
}
System.print("\n")
var bia = [
BigInt.new("4547337172376300111955330758342147474062293202868155909489"),
BigInt.new("4547337172376300111955330758342147474062293202868155909393")
]
for (bi in bia) {
System.print("%(bi) is %(bi.isProbablePrime(iters) ? "probably prime" : "composite")")
}</lang>
 
{{out}}
<pre>
The following numbers less than 100 are prime:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
 
4547337172376300111955330758342147474062293202868155909489 is probably prime
4547337172376300111955330758342147474062293202868155909393 is composite
</pre>
 
=={{header|zkl}}==
9,476

edits