Jump to content

Miller–Rabin primality test: Difference between revisions

m
Line 3,199:
=={{header|Phix}}==
{{trans|C}}
=== native, determinstic to 94,910,107 ===
Native-types deterministic version, fails (false negative) at 94,910,107 on 32-bit [fully tested, ie from 1],
and at 4,295,041,217 on 64-bit [only tested from 4,290,000,000] - those limits have now been hard-coded below.
Line 3,278 ⟶ 3,279:
999991 is composite
</pre>
=== second version, deterministic to 341,550,071,728,321 ===
{{libheader|bigatom}}
The same using bigatoms, obviously significantly slower, deterministic up to 341,550,071,728,321<br>
Line 3,405 ⟶ 3,407:
42.61s
</pre>
===better third version, this time actually using the pseudocode above ===
After (finally) using ba_mod_exp() based on FastExp() in the Liberty BASIC submission (and boy did this need it!).,
I thought I'd cracked it, but this is still marginally slower than the second version.
<lang Phix>-- demo/rosetta/Miller_Rabin_primality_test.exw
include bigatom.e
7,820

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.