diff --git a/cmd/gcd.go b/cmd/gcd.go index e49211e..48e875f 100644 --- a/cmd/gcd.go +++ b/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)