GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* Classify numbers as probable primes, primes or composites.1With -q return true if the following argument is a (probable) prime.23Copyright 1999, 2000, 2002, 2005, 2012 Free Software Foundation, Inc.45This program is free software; you can redistribute it and/or modify it under6the terms of the GNU General Public License as published by the Free Software7Foundation; either version 3 of the License, or (at your option) any later8version.910This program is distributed in the hope that it will be useful, but WITHOUT ANY11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A12PARTICULAR PURPOSE. See the GNU General Public License for more details.1314You should have received a copy of the GNU General Public License along with15this program. If not, see https://www.gnu.org/licenses/. */1617#include <stdlib.h>18#include <string.h>19#include <stdio.h>20#include "gmp.h"2122char *progname;2324void25print_usage_and_exit ()26{27fprintf (stderr, "usage: %s -q nnn\n", progname);28fprintf (stderr, "usage: %s nnn ...\n", progname);29exit (-1);30}3132int33main (int argc, char **argv)34{35mpz_t n;36int i;3738progname = argv[0];3940if (argc < 2)41print_usage_and_exit ();4243mpz_init (n);4445if (argc == 3 && strcmp (argv[1], "-q") == 0)46{47if (mpz_set_str (n, argv[2], 0) != 0)48print_usage_and_exit ();49exit (mpz_probab_prime_p (n, 25) == 0);50}5152for (i = 1; i < argc; i++)53{54int class;55if (mpz_set_str (n, argv[i], 0) != 0)56print_usage_and_exit ();57class = mpz_probab_prime_p (n, 25);58mpz_out_str (stdout, 10, n);59if (class == 0)60puts (" is composite");61else if (class == 1)62puts (" is a probable prime");63else /* class == 2 */64puts (" is a prime");65}66exit (0);67}686970