package main import ( "fmt" "math/big" ) func main() { a := big.NewInt(123456789) b := big.NewInt(987654321) c := big.NewInt(0) c.Add(a, b) fmt.Println(c) }
package main import ( "fmt" "math/big" ) func factorial(n int64) *big.Int { if n == 0 { return big.NewInt(1) } bigN := big.NewInt(n) return bigN.Mul(bigN, factorial(n-1)) } func main() { fmt.Println(factorial(100)) }This code defines a function `factorial` that computes the factorial of a given integer using arbitrary-precision arithmetic. It uses a recursive algorithm to multiply the current integer by the factorial of the previous integer. The `main` function calls `factorial` with a value of 100, which is a very large number. The result is printed out using the `fmt.Println` function. In conclusion, `go math/big` is a package library in Go language that provides arbitrary-precision arithmetic for integers and floating-point numbers. It is used in tasks requiring precise computations, such as cryptography and scientific computing.