> (1) (2) (3)

advertisement
Miller-Rabin Primality Test
>
Pick n whose primality we want to test:
>
(1)
>
(2)
>
(3)
Thus n-1 = 2^k*q, with q odd:
>
8632
(4)
Pick test value a:
>
(5)
Check that a and n are relatively prime: if they are not, then we have factored n.
>
1
(6)
The following command is entered in 'Maple input mode' by hitting ctrl-m (or use Insert -> Maple Input
dropdown menu). The purpose of this command is to force Maple to use successive squaring to
calculate the exponentiation a^q mod n --- useful for reasonable run-time when q and n are large.
> b := a&^q mod n;
(7)
If b is 1, then Miller-Rabin test fails, so go back and pick a different a. Otherwise,
>
(8)
>
Download