go - Go 中的 bigInt 包中是否有 pow 方法

标签 go

我正在查看 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/

相关文章:

go - 如何使用备用 go.mod 文件进行本地开发?

go - golang 中的 C 风格条件编译

mongodb - golang mongo-db 事务无法创建命名空间

javascript - 创建一个双头动态表,其中填充了从 golang 服务器提取的三个不同数组的元素

Go HTTP ListenAndServe 记录响应

go - 马提尼绑定(bind) "cannot return value obtained from unexported field or method"

go - golang中map的Big O表现如何?

pointers - 通过将指针传递给 Go 中的函数来获取不同的值

sorting - golang sort.Sort随机输出并且是错误的

arrays - 如何将一个空结构编码(marshal)为一个空数组