make pointers so we don't dereference constantly
This commit is contained in:
parent
f7cc2a9dd3
commit
c6b9c1586e
16
cmd/gcd.go
16
cmd/gcd.go
|
|
@ -27,10 +27,10 @@ import (
|
|||
var extended bool
|
||||
|
||||
func gcd(cmd *cobra.Command, args []string) {
|
||||
var x big.Int
|
||||
var y big.Int
|
||||
var z big.Int
|
||||
var w big.Int
|
||||
x := new(big.Int)
|
||||
y := new(big.Int)
|
||||
z := new(big.Int)
|
||||
w := new(big.Int)
|
||||
|
||||
bezouts := make([]big.Int, len(args))
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ func gcd(cmd *cobra.Command, args []string) {
|
|||
log.Fatal("invalid input " + s)
|
||||
}
|
||||
|
||||
z.GCD(&x, &y, &z, &w)
|
||||
z.GCD(x, y, z, w)
|
||||
|
||||
if !extended {
|
||||
continue
|
||||
|
|
@ -48,15 +48,15 @@ func gcd(cmd *cobra.Command, args []string) {
|
|||
|
||||
for j, c := range bezouts {
|
||||
if j == i {
|
||||
bezouts[j].Set(&y)
|
||||
bezouts[j].Set(y)
|
||||
} else {
|
||||
bezouts[j].Mul(&c, &x)
|
||||
bezouts[j].Mul(&c, x)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Print(&z)
|
||||
fmt.Print(z)
|
||||
if extended {
|
||||
for _, c := range bezouts {
|
||||
fmt.Printf(" %s", &c)
|
||||
|
|
|
|||
Loading…
Reference in New Issue