This library adds several functions useful for doing math on integers. Machine integers (and any other non-BigInt Integer type) use native Julia algorithms; BigInt inputs use GMP.
Functions
iroot(x::Integer, n::Integer)the integer nth root ofx, truncated toward zero: forx >= 0the largest integerasuch thata^n <= x, andiroot(-x, n) == -iroot(x, n)for oddn(e.g.iroot(-9, 3) == -2). Throws aDomainErrorforn <= 0or an even root of a negative number.rootrem(x::Integer, n::Integer)returns(iroot(x, n), x - iroot(x, n)^n).ispower(x::Integer)returns whether there are integerbaseandexponent > 1values such thatbase^exponent == x. For negativexonly odd exponents count, soispower(-8) == truebutispower(-4) == false.0and±1are perfect powers.find_exponent(x::Integer)returns the largest possible integerexponentsuch thatbase^exponent == xfor somebase(only odd exponents for negativex). Returns1forx ∈ [-1, 1].is_probably_prime(x::Integer; reps=25)returns ifxis prime. Will be incorrect less than4^-repsof the time.kronecker(a::Integer, n::Integer)Computes the Kronecker symbol which is a generalization of the legendre and jacobi symbols.