Miller–Rabin primality test: Difference between revisions

→‎{{header|Scheme}}: Small change to ow composite-witness? is phrased
(R6RS Scheme)
(→‎{{header|Scheme}}: Small change to ow composite-witness? is phrased)
Line 4,125:
(let*-values (((s d) (split (- n 1)))
((x) (modexpt a d n)))
(condand (not (= x 1))
(not (= x (- n 1) #f))
((=let xtry ((r (- ns 1)) #f)
(andset! (notx (=modexpt x (-2 n 1)))
(else
(let try ((ror (-zero? s 1))r)
(set! x (modexpt= x 2 n)1)
(orand (zero?not (= x (- n r1)))
(try (=- xr 1))))))))
(and (not (= x (- n 1)))
(try (- r 1)))))))))
 
;; Test whether n > 2 is a Miller-Rabin pseudoprime, k trials.
Anonymous user