def python_sqrt(n): return int(mlib.isqrt(n))
# # At this point gmpy will be None if gmpy2 was not successfully imported or if # the environment variable SYMPY_GROUND_TYPES was set to 'python' (or some # unrecognised value). The two blocks below define the values exported by this # module in each case. # SYMPY_INTS: tTuple[Type, ...] if gmpy is not None: HAS_GMPY = 2 GROUND_TYPES = 'gmpy' SYMPY_INTS = (int, type(gmpy.mpz(0))) MPZ = gmpy.mpz MPQ = gmpy.mpq factorial = gmpy.fac sqrt = gmpy.isqrt else: from .pythonmpq import PythonMPQ HAS_GMPY = 0 GROUND_TYPES = 'python' SYMPY_INTS = (int, ) MPZ = int MPQ = PythonMPQ factorial = lambda x: int(mlib.ifac(x)) sqrt = lambda x: int(mlib.isqrt(x))
def python_sqrt(n): return int(mlib.isqrt(n))
def isqrt_floor(x): if not isinstance(x, int): raise FunctionError('isqrt: unsupported argument type') if x < 0: raise FunctionError('isqrt: x < 0') return isqrt(x)