Miller–Rabin primality test: Difference between revisions

m
Fixed lang tags.
m (Fixed lang tags.)
Line 28:
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<!-- {{does not work with|ELLA ALGOL 68|Any (with appropriate job cards AND formatted transput statements removed) - tested with release 1.8.8d.fc9.i386 - ELLA has no FORMATted transput, also it generates a call to undefined C LONG externals }} -->
<lang algolalgol68>MODE LINT=LONG INT;
MODE LOOPINT = INT;
 
Line 73:
=={{header|AutoHotkey}}==
ahk forum: [http://www.autohotkey.com/forum/post-276712.html#276712 discussion]
<lang AutoHotkey>MsgBox % MillerRabin(999983,10) ; 1
MsgBox % MillerRabin(999983,10) ; 1
MsgBox % MillerRabin(999809,10) ; 1
MsgBox % MillerRabin(999727,10) ; 1
Line 289 ⟶ 288:
=={{header|Common Lisp}}==
 
<lang lisp>(defun factor-out (number divisor)
(defun factor-out (number divisor)
"Return two values R and E such that NUMBER = DIVISOR^E * R,
and R is not divisible by DIVISOR."
Line 332 ⟶ 330:
thereis (= y (- n 1)))))))
(loop repeat k
always (strong-liar? (random-in-range 2 (- n 2)))))))))</lang>
</lang>
<pre>
CL-USER> (last (loop for i from 1 to 1000
Line 473 ⟶ 470:
Another Miller Rabin test can be found in D. Amos's Haskell for Math module [http://www.polyomino.f2s.com/david/haskell/numbertheory.html Primes.hs]
 
<lang Haskell>import System.Random
import System.Random
import Data.List
import Control.Monad
Line 544 ⟶ 540:
>>> [ i for i in range(1,1000) if miller_rabin(i, 10)][-10:]
[937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
>>> </lang>
 
=={{header|Ruby}}==
Anonymous user