FLINT3.7.0-dev

fmpz_factor_ecm

Synopsis#include <flint/fmpz_factor.h>
int fmpz_factor_ecm(fmpz_t f, ulong curves, ulong B1, ulong B2, flint_rand_t state, const fmpz_t n_in)source

Looks for a factor of n = n_in by Lenstra's elliptic curve method [Len1987] with Montgomery's curves and arithmetic [Mon1987], trying up to curves random curves with stage 1 bound B1 and stage 2 bound B2 (B_1 < B_2). Returns 1 if a factor is found in stage 1, 2 if it is found in stage 2, -1 if it is found while setting up a curve, and 0 otherwise; the factor (not necessarily prime) is written to f. Single-word n are passed to n_factor_ecm.

The curves are distributed over the available threads (the result is the factor found by the curve of lowest index, so it does not depend on the number of threads). See The elliptic curve method for the stages and the parameter choice.

References#

  • [Len1987] H. W. Lenstra, Jr., "Factoring integers with elliptic curves", Annals of Mathematics 126 (1987), 649–673
  • [Mon1987] P. L. Montgomery, "Speeding the Pollard and elliptic curve methods of factorization", Mathematics of Computation 48 (1987), 243-264, https://doi.org/10.1090/S0025-5718-1987-0866113-7
Cite this page

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