diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index 31e3b035d64..dd4ea568589 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=0897c667d1327d2a51ea3d3bd1d9e1a3f5ca2606 -md5=a1f271e5ffcf558d054028839296a072 -cksum=437557471 +sha1=b26cd9a17917ab6dd2f601e7448929fc9c09767d +md5=4d0234e98408d5a3c6c8b6d5075cc53d +cksum=550848071 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 9462f03cbd2..f571ea502bb 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -08185d786047228caff879eba88a1f8148a49020 +0ce2ea5d3d899264aef63cea22b27b209b60bec8 diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 67d51b74ab4..67a30c01001 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -2951,13 +2951,21 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return n - def prime_divisors(self): + def prime_divisors(self, *args, **kwds): """ Return the prime divisors of this integer, sorted in increasing order. If this integer is negative, we do *not* include -1 among its prime divisors, since -1 is not a prime number. + INPUT: + + - ``limit`` -- (integer, optional keyword argument) + Return only prime divisors up to this bound, and the factorization + is done by checking primes up to ``limit`` using trial division. + + Any additional arguments are passed on to the :meth:`factor` method. + EXAMPLES:: sage: a = 1; a.prime_divisors() @@ -2968,8 +2976,23 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): [2, 5] sage: a = 2004; a.prime_divisors() [2, 3, 167] + + Setting the optional ``limit`` argument works as expected:: + + sage: a = 10^100 + 1 + sage: a.prime_divisors() + [73, 137, 401, 1201, 1601, 1676321, 5964848081, + 129694419029057750551385771184564274499075700947656757821537291527196801] + sage: a.prime_divisors(limit=10^3) + [73, 137, 401] + sage: a.prime_divisors(limit=10^7) + [73, 137, 401, 1201, 1601, 1676321] """ - return [r[0] for r in self.factor()] + res = [r[0] for r in self.factor(*args, **kwds)] + limit = kwds.get('limit') + if limit is not None: + res = [r for r in res if r <= limit] + return res prime_factors = prime_divisors