我正在查看 documentation of a big integer arithmetic在 Go 中并尝试找到适合计算 a^n 的方法(类似于 python 中的 pow(a, n)
)。
令我惊讶的是一些简单的函数,如 GCD , Binomial并不像modinverse那么简单我找不到战俘。我错过了吗?还是我应该自己写?
最佳答案
func (z *Int) Exp(x, y, m *Int) *Int
Exp sets z = x^y mod |m| (i.e. the sign of m is ignored), and returns z. If y <= 0, the result is 1 mod |m|; if m == nil or m == 0, z = x^y. See Knuth, volume 2, section 4.6.3.
关于go - Go 中的 bigInt 包中是否有 pow 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30011720/