Programming Language: Golang

Namespace/Package Name: math/big

Class/Type: Int

Method/Function: ModInverse

Examples at hotexamples.com: 29

The big.Int.ModInverse method in the Go math package is used to find the modular inverse of a big integer. The method takes in two arguments, the big integer and the modulo, and returns the inverse if it exists.

**Example 1:**

In this example, we are finding the modular inverse of the number 7 with respect to modulo 11. The result is printed as 8.

**Example 2:**

package main import ( "fmt" "math/big" ) func main() { n := big.NewInt(7) mod := big.NewInt(11) inv := new(big.Int).ModInverse(n, mod) fmt.Println(inv) }

In this example, we are finding the modular inverse of the number 7 with respect to modulo 11. The result is printed as 8.

package main import ( "fmt" "math/big" ) func main() { n := big.NewInt(10) mod := big.NewInt(3) inv := new(big.Int).ModInverse(n, mod) fmt.Println(inv) }In this example, we are finding the modular inverse of the number 10 with respect to modulo 3. However, since the inverse does not exist, the method returns nil. The package library for the big.Int.ModInverse method is math/big.

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related