Qurak

PowerMod

可用,与 .wl 参考有差异

Fast modular exponentiation — `PowerMod[b, e, m] == Mod[b^e, m]`.

`PowerMod[a, b, m]` computes `a^b mod m`. Modular inverses - the `b = -1` form - are the exception: above roughly 61-bit moduli the call returns unevaluated while smaller moduli work, which is exactly the field size cryptographic work uses. Until that is fixed, compute the inverse with `ExtendedGCD[a, m][[2, 1]]`, which is reliable at any size and returns the same value (reduce it with `Mod[..., m]` if you need the canonical representative).

PowerMod[a, b, m]
PowerMod[a, -1, m]
PowerMod[a, 1/ r, m]
PowerMod[2, 10, 100] → 24PowerMod[5, 1/3, 11] → 3

用于

主题

相关

全部 6300 个函数 · 从 MCP 客户端使用