We pass to massive numbers (big.Int)

I am trying to split two massive numbers (for example, trying to split 50! By 18!), And I have two large variables. Inside the variables.

first.MulRange(1,50)

second.MulRange(1,18)

How can I split numbers (ideally with integer division)?

Thanks!

+6
source share
1 answer

How can I split the numbers

Calling the Div () method Int(in this case) a data type. (package "math / big")

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())

Result:

First: 30414093201713378043612608166064768844377641568960512000000000000
Second: 6402373705728000
Division result: 4750440164794325701367714688167999176704000000000
+6
source

All Articles