1
/* Classify numbers as probable primes, primes or composites.
2
With -q return true if the folowing argument is a (probable) prime.
4
Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify it under
7
the terms of the GNU General Public License as published by the Free Software
8
Foundation; either version 2 of the License, or (at your option) any later
11
This program is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License along with
16
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17
Place - Suite 330, Boston, MA 02111-1307, USA. */
25
print_usage_and_exit ()
27
fprintf (stderr, "usage: %s -q nnn\n", progname);
28
fprintf (stderr, "usage: %s nnn ...\n", progname);
33
main (int argc, char **argv)
41
print_usage_and_exit ();
45
if (argc == 3 && strcmp (argv[1], "-q") == 0)
47
if (mpz_set_str (n, argv[2], 0) != 0)
48
print_usage_and_exit ();
49
exit (mpz_probab_prime_p (n, 5) == 0);
52
for (i = 1; i < argc; i++)
55
if (mpz_set_str (n, argv[i], 0) != 0)
56
print_usage_and_exit ();
57
class = mpz_probab_prime_p (n, 5);
58
mpz_out_str (stdout, 10, n);
60
puts (" is composite");
62
puts (" is a probable prime");