diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 9fe86a04c6b..6969cf26cc5 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2775,9 +2775,7 @@ def radical(n, *args, **kwds): sage: radical(2 * 3^2 * 5^5) 30 sage: radical(0) - Traceback (most recent call last): - ... - ArithmeticError: radical of 0 is not defined + 0 sage: K. = QuadraticField(-1) # needs sage.rings.number_field sage: radical(K(2)) # needs sage.rings.number_field i - 1 diff --git a/src/sage/categories/unique_factorization_domains.py b/src/sage/categories/unique_factorization_domains.py index a9704872d84..f0ead13aebc 100644 --- a/src/sage/categories/unique_factorization_domains.py +++ b/src/sage/categories/unique_factorization_domains.py @@ -262,9 +262,7 @@ def radical(self, *args, **kwds): sage: Integer(-100).radical() 10 sage: Integer(0).radical() - Traceback (most recent call last): - ... - ArithmeticError: radical of 0 is not defined + 0 The next example shows how to compute the radical of a number, assuming no prime > 100000 has exponent > 1 in the factorization:: diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 358aac0339c..72fa6d247cb 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -5911,6 +5911,25 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): flag = self < 0 and proof return objtogen(self).qfbclassno(flag).sage() + def radical(self, *args, **kwds): + """ + Return the radical of this integer, i.e., the product of its + prime divisors. + + EXAMPLES:: + + sage: 0.radical() + 0 + sage: 10.radical() + 10 + sage: (-12).radical() + 6 + """ + if self.is_zero(): + return self + + return self.factor(*args, **kwds).radical_value() + def squarefree_part(self, long bound=-1): r""" Return the square free part of `x` (=``self``), i.e., the unique integer