package main import ( "fmt" "math/big" ) func main() { x := big.NewInt(50) y := big.NewInt(8) var q, r big.Int q.DivMod(x, y, &r) fmt.Printf("quotient: %v, remainder: %v\n", &q, &r) }
quotient: 6, remainder: 2
package main import ( "fmt" "math/big" ) func main() { x := big.NewInt(123456789) y := big.NewInt(987654321) var q, r big.Int q.DivMod(x, y, &r) fmt.Printf("quotient: %v, remainder: %v\n", &q, &r) }
quotient: 0, remainder: 123456789In this example, we divide `x` by `y`, which results in a quotient of 0 and a remainder of `x` itself. This demonstrates that `DivMod` returns the correct values even when the dividend is smaller than the divisor. The `math/big` package is a standard library in Go.