Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 =head1 NAME
7 isprime - probabilistic primality testing
9 =head1 SYNOPSIS
11 isprime <a>
13 =head1 DESCRIPTION
15 The B<isprime> program attempts to determine whether the arbitrary
16 precision integer I<a> is prime. It first tests I<a> for divisibility
17 by the first 170 or so small primes, and assuming I<a> is not
18 divisible by any of these, applies 15 iterations of the Rabin-Miller
19 probabilistic primality test.
21 If the program discovers that the number is composite, it will print:
23 Not prime (reason)
25 Where I<reason> is either:
27 divisible by small prime x
29 Or:
31 failed nth pseudoprime test
33 In the first case, I<x> indicates the first small prime factor that
34 was found. In the second case, I<n> indicates which of the
35 pseudoprime tests failed (numbered from 1)
37 If this happens, the number is definitely not prime. However, if the
38 number succeeds, this message results:
40 Probably prime, 1 in 4^15 chance of false positive
42 If this happens, the number is prime with very high probability, but
43 its primality has not been absolutely proven, only demonstrated to a
44 very convincing degree.
46 The value I<a> can be input in standard decimal notation, or, if it is
47 prefixed with I<Ox>, it will be read as hexadecimal.
49 =head1 ENVIRONMENT
51 You can control how many iterations of Rabin-Miller are performed on
52 the candidate number by setting the I<RM_TESTS> environment variable
53 to an integer value before starting up B<isprime>. This will change
54 the output slightly if the number passes all the tests.
56 =head1 SEE ALSO
58 gcd(1), invmod(1), lap(1)
60 =head1 AUTHOR
62 Michael J. Fromberger <sting@linguist.dartmouth.edu>
63 Thayer School of Engineering, Hanover, New Hampshire, USA