Anonymous user
Miller–Rabin primality test: Difference between revisions
→{{header|Ruby}}
Line 4,487:
</lang>
=== This is a correct M-R test implementation for using bases > input. ===
==== It is deterministic for all integers < 3_317_044_064_679_887_385_961_981.====
==== Increase 'primes' array members for more "confidence" past this value. ====
<lang ruby>
Line 4,514 ⟶ 4,515:
d >>= 4 while (d & 0xf) == 0 # suck out factors of 2
(d >>= (d & 3)^2; d >>= (d & 1)^1) if d.even? # 4 bits at a time
witnesses.each do |b| #
next if (b % self) == 0 # **skip base if a multiple of input**
s = d
|