Tim Peters <[email protected]> added the comment:
- Some form of this would be most welcome!
- If it's spelled this way, put the modulus argument last? "Everyone expects"
the modulus to come last, whether in code:
x = (a+b) % m
x = a*b % m
x = pow(a, b, m)
or in math:
a^(k*(p-1)) = (a^(p-1))^k = 1^k = 1 (mod p)
- Years ago Guido signed off on spelling this
pow(value, -1, modulus)
which currently raises an exception. Presumably
pow(value, -n, modulus)
for int n > 1 would mean the same as pow(pow(value, -1, modulus), n, modulus),
if it were accepted at all. I'd be happy to stop with -1.
- An alternative could be to supply egcd(a, b) returning (g, x, y) such that
a*x + b*y == g == gcd(a, b)
But I'm not sure anyone would use that _except_ to compute modular inverse. So
probably not.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36027>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com