[issue36027] Consider adding modular multiplicative inverse to the math module
Raymond Hettinger
report at bugs.python.org
Tue Feb 19 13:27:48 EST 2019
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
> +1 for the pow(value, -1, modulus) spelling. It should raise
> `ValueError` if `value` and `modulus` are not relatively prime.
> It would feel odd to me _not_ to extend this to
> `pow(value, n, modulus)` for all negative `n`, again
> valid only only if `value` is relatively prime to `modulus`.
I'll work up a PR using the simplest implementation. Once that's in with tests and docs, it's fair game for someone to propose algorithmic optimizations.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36027>
_______________________________________
More information about the Python-bugs-list
mailing list