1 /* Exercise mpz_probab_prime_p.
3 Copyright 2002 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
29 - Test some big primes don't come back claimed to be composite.
30 - Test some big composites don't come back claimed to be certainly prime.
31 - Test some big composites with small factors are identified as certainly
35 /* return 1 if prime, 0 if composite */
50 for (i = 3; i < n; i++)
58 check_one (mpz_srcptr n, int want)
62 got = mpz_probab_prime_p (n, 25);
64 /* "definitely prime" is fine if we only wanted "probably prime" */
65 if (got == 2 && want == 1)
70 printf ("mpz_probab_prime_p\n");
72 printf (" got =%d", got);
73 printf (" want=%d", want);
79 check_pn (mpz_ptr n, int want)
86 /* expect certainty for small n */
95 for (i = 0; i < 300; i++)
98 check_pn (n, isprime (i));