display as fraction
This commit is contained in:
parent
f5d0ff1e61
commit
385e2f4a80
|
|
@ -54,16 +54,21 @@ func convergents(cmd *cobra.Command, args []string) {
|
|||
|
||||
seq(h, hprev, a0)
|
||||
seq(k, kprev, a0)
|
||||
fmt.Println(h, k)
|
||||
|
||||
r := new(big.Rat).SetFrac(h, k)
|
||||
fmt.Println(r)
|
||||
|
||||
for i := 0; true; i = (i + 1) % len(denoms) {
|
||||
a := &denoms[i]
|
||||
seq(h, hprev, a)
|
||||
seq(k, kprev, a)
|
||||
fmt.Println(h, k)
|
||||
|
||||
r.SetFrac(h, k)
|
||||
fmt.Println(r)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: should support an initial block of non-periodic denominators (will need flags)
|
||||
// convergentsCmd represents the convergents command
|
||||
var convergentsCmd = &cobra.Command{
|
||||
Use: "convergents N N [N ...]",
|
||||
|
|
|
|||
Loading…
Reference in New Issue