From 67c95db7bae7723b2d21983e3b2e2704b333ce22 Mon Sep 17 00:00:00 2001 From: filifa Date: Sat, 6 Sep 2025 00:04:26 -0400 Subject: [PATCH] reorganize loop --- cmd/convergents.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/convergents.go b/cmd/convergents.go index aab1ba8..28eb5fd 100644 --- a/cmd/convergents.go +++ b/cmd/convergents.go @@ -42,13 +42,15 @@ func gaussianBrackets(ch <-chan *big.Int) <-chan *big.Int { x := big.NewInt(1) go func() { - out <- big.NewInt(1) + tmp := new(big.Int) for a := range ch { - tmp := new(big.Int).Mul(a, x) + out <- x + + tmp.Mul(a, x) tmp.Add(tmp, xprev) + xprev.Set(x) - x.Set(tmp) - out <- tmp + x = new(big.Int).Set(tmp) } }()