compute convergents with channels
This commit is contained in:
19
cmd/pell.go
19
cmd/pell.go
@@ -39,16 +39,13 @@ func pell(cmd *cobra.Command, args []string) {
|
||||
cobra.CheckErr(pellCoeff + " is a perfect square")
|
||||
}
|
||||
|
||||
hprev := big.NewInt(0)
|
||||
kprev := big.NewInt(1)
|
||||
hch := make(chan *big.Int)
|
||||
kch := make(chan *big.Int)
|
||||
go gaussianBrackets(a0, big.NewInt(1), repetend, hch)
|
||||
go gaussianBrackets(big.NewInt(1), big.NewInt(0), repetend, kch)
|
||||
|
||||
h := big.NewInt(1)
|
||||
k := big.NewInt(0)
|
||||
|
||||
gaussianBrackets(h, hprev, a0)
|
||||
gaussianBrackets(k, kprev, a0)
|
||||
|
||||
for i := 0; true; i = (i + 1) % len(repetend) {
|
||||
for {
|
||||
h, k := <-hch, <-kch
|
||||
foo := new(big.Int).Exp(k, big.NewInt(2), nil)
|
||||
foo.Mul(d, foo)
|
||||
|
||||
@@ -58,10 +55,6 @@ func pell(cmd *cobra.Command, args []string) {
|
||||
if bar.Cmp(big.NewInt(1)) == 0 {
|
||||
fmt.Println(h, k)
|
||||
}
|
||||
|
||||
a := repetend[i]
|
||||
gaussianBrackets(h, hprev, a)
|
||||
gaussianBrackets(k, kprev, a)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user