GMPY2 (or GMP) has a powmod
function but I can't find anything for regular exponentiation aside from python's native pow
. Does a function like this exist for mpz
integers?
Just use Python's standard pow()
function or the exponentiation **
operator. GMPY2's mpz
type overloads all the standard special methods so you should just be able to use standard Python commands.
For example:
>>> from gmpy2 import mpz
>>> pow(mpz(3),7)
mpz(2187)
>>> pow(mpz(3),7,13)
mpz(3)
>>> mpz(3)**7
mpz(2187)
>>>
The same holds true for divmod(), etc.