FLINT3.7.0-dev

fmpz_is_prime

Synopsis#include <flint/fmpz.h>
int fmpz_is_prime(const fmpz_t n)source

Returns 1 if n is prime and 0 otherwise, with a proof.

After the tests of fmpz_is_probabprime (which settle every n up to about 81 bits on 64-bit machines), the function trial factors n - 1 and n + 1 and tries the Pocklington, Morrison and Brillhart–Lehmer–Selfridge tests [BLS1975]. If these do not succeed, the proof is done by ECPP (ecpp_is_prime) from 250 bits with one thread (the crossover rises with the number of threads) and by APRCL (aprcl_is_prime) otherwise. If neither can decide, an exception is raised; this is not expected to happen.

References#

  • [BLS1975] J. Brillhart, D. H. Lehmer and J. L. Selfridge, "New primality criteria and factorizations of 2^m ± 1", Mathematics of Computation 29 (1975), 620–647
Cite this page

The FLINT team, “fmpz_is_prime (fmpz.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpz/fmpz_is_prime.html (generated 2026-10-20).