FLINT3.7.0-dev

n_factor_trial, n_factor_trial_range

Synopsis#include <flint/ulong_extras.h>
ulong n_factor_trial(n_factor_t * factors, ulong n, ulong num_primes)source
ulong n_factor_trial_range(n_factor_t * factors, ulong n, ulong start, ulong num_primes)source

Trial division by the first num_primes primes (starting at the prime with index start). Factors found are added to factors, which must be initialised; the unfactored cofactor is returned.

The functions call n_compute_primes as needed and divide with n_remove2_precomp using the cached double inverses. They stop as soon as the square of the current prime exceeds the cofactor.

Cite this page

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