Integer factorization using PARI#

AUTHORS:

  • Jeroen Demeyer (2015)

sage.rings.factorint_pari.factor_using_pari(n, int_=False, debug_level=0, proof=None)[source]#

Factor this integer using PARI.

This function returns a list of pairs, not a Factorization object. The first element of each pair is the factor, of type Integer if int_ is False or int otherwise, the second element is the positive exponent, of type int.

INPUT:

  • int_ – (default: False), whether the factors are of type int instead of Integer

  • debug_level – (default: 0), debug level of the call to PARI

  • proof – (default: None), whether the factors are required to be proven prime; if None, the global default is used

OUTPUT:

A list of pairs.

EXAMPLES:

sage: factor(-2**72 + 3, algorithm='pari')  # indirect doctest
-1 * 83 * 131 * 294971519 * 1472414939
>>> from sage.all import *
>>> factor(-Integer(2)**Integer(72) + Integer(3), algorithm='pari')  # indirect doctest
-1 * 83 * 131 * 294971519 * 1472414939

Check that PARI’s debug level is properly reset (Issue #18792):

sage: alarm(0.5); factor(2^1000 - 1, verbose=5)
Traceback (most recent call last):
...
AlarmInterrupt
sage: pari.get_debug_level()
0
>>> from sage.all import *
>>> alarm(RealNumber('0.5')); factor(Integer(2)**Integer(1000) - Integer(1), verbose=Integer(5))
Traceback (most recent call last):
...
AlarmInterrupt
>>> pari.get_debug_level()
0