I'm trying to divide two massive numbers (e.g. trying to divide 50! by 18!) and I have two big.Int variables set.
first.MulRange(1,50)
second.MulRange(1,18)
How can I divide the numbers (ideally with integer division)?
Thanks!
How can I divide the numbers
By invoking Div() method of Int
(in this case) data type. ("math/big" package)
first := new(big.Int).MulRange(1, 50)
second := new(big.Int).MulRange(1, 18)
fmt.Printf("First: %s \n", first.String())
fmt.Printf("Second: %s \n", second.String())
// division
dv := new(big.Int).Div(first, second)
fmt.Printf("Division result: %s \n", dv.String())
The result:
First: 30414093201713378043612608166064768844377641568960512000000000000
Second: 6402373705728000
Division result: 4750440164794325701367714688167999176704000000000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With