消息 [335888]
- 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. |
|
| 日期 |
用户 |
动作 |
参数 |
| 2019-02-19 05:34:15 | tim.peters | 修改 | recipients:
+ tim.peters, rhettinger, mark.dickinson, steven.daprano, skrah, pablogsal |
| 2019-02-19 05:34:15 | tim.peters | 修改 | messageid: <1550554455.13.0.54003501046.issue36027@roundup.psfhosted.org> |
| 2019-02-19 05:34:15 | tim.peters | 链接 | issue36027 messages |
| 2019-02-19 05:34:15 | tim.peters | 创建 | |
|