n_is_prime_pseudosquare
#include <flint/ulong_extras.h>Primality test based on pseudosquares, following Theorem 2.7 of [LukPatWil1996].
n_is_prime_pseudosquare first trial-divides by up to FLINT_PSEUDOSQUARES_CUTOFF primes; if no factor is found and the square of the last prime does not exceed , let be the next prime. The first pseudosquare is then looked up in a static table (OEIS A002189), and step 3 of the test checks that for the primes up to . Every prime passes this, and most composites fail. If , is then prime. Otherwise step 4 proves primality: for by checking , and for by finding some with , trying further primes if necessary. Step 4 cannot fail for prime ; if it ever fails, an exception is thrown, since a composite passing step 3 would be of independent interest.
References#
- [LukPatWil1996] R. F. Lukes and C. D. Patterson and H. C. Williams "Some results on pseudosquares" Math. Comp. 1996, no. 65, 361–372
The FLINT team, “n_is_prime_pseudosquare (ulong_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ulong_extras/n_is_prime_pseudosquare.html (generated 2026-11-02).
@misc{flint-doc-ulong-extras-n-is-prime-pseudosquare,
author = {{The FLINT team}},
title = {{n\_is\_prime\_pseudosquare (ulong\_extras.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/ulong_extras/n_is_prime_pseudosquare.html},
note = {Generated 2026-11-02}
}