Integer factorization using FLINT

AUTHORS:

  • Michael Orlitzky (2023)

sage.rings.factorint_flint.factor_using_flint(n)[source]

Factor the nonzero integer n using FLINT.

This function returns a list of (factor, exponent) pairs. The factors will be of type Integer, and the exponents will be of type int.

INPUT:

  • n – a nonzero sage Integer; the number to factor

OUTPUT:

A list of (Integer, int) pairs representing the factors and their exponents.

EXAMPLES:

   sage: from sage.rings.factorint_flint import factor_using_flint
   sage: n = ZZ(9962572652930382)
   sage: factors = factor_using_flint(n)
   sage: factors
   [(2, 1), (3, 1), (1660428775488397, 1)]
   sage: prod( f^e for (f,e) in factors ) == n
   True

Negative numbers will have a leading factor of ``(-1)^1``::

   sage: n = ZZ(-1 * 2 * 3)
   sage: factor_using_flint(n)
   [(-1, 1), (2, 1), (3, 1)]

The factorization of unity is empty:

sage: factor_using_flint(ZZ.one())
[]
>>> from sage.all import *
>>> factor_using_flint(ZZ.one())
[]
factor_using_flint(ZZ.one())

While zero has a single factor, of… zero:

sage: factor_using_flint(ZZ.zero())
[(0, 1)]
>>> from sage.all import *
>>> factor_using_flint(ZZ.zero())
[(0, 1)]
factor_using_flint(ZZ.zero())