diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-30 17:54:17 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-30 20:02:26 -0500 |
| commit | aa73f47a5e2535224aa772f163aed2b6802bd4ad (patch) | |
| tree | e516fc505540eaa27abeb78214984d582c58c29c /factor_info.go | |
| parent | 0f698d42907bc06f469ae3311433bcc741b8bd9b (diff) | |
Add compact display
Diffstat (limited to 'factor_info.go')
| -rw-r--r-- | factor_info.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/factor_info.go b/factor_info.go index ee04e32..a6b91a9 100644 --- a/factor_info.go +++ b/factor_info.go @@ -95,6 +95,22 @@ func (fi *FactorInfo) WriteTo(w io.Writer) { } } +func (fi *FactorInfo) WriteToCompact(w io.Writer) { + fmt.Fprintf(w, "%d = %s | σ(n)/n: %.2f | τ(n)/n: %.3f | 2345: %s\n", + fi.Radix, fi.PrimeFactorization, fi.Score, fi.TotativeRatio, fi.BasicRank) + fmt.Fprintf(w, "Ln: %.2f", fi.Ln) + if fi.MTC != nil { + fmt.Fprintf(w, " | MTC: %d", *fi.MTC) + } + if fi.Type != nil { + fmt.Fprintf(w, " | %s", typeAbbrev(*fi.Type)) + } + fmt.Fprintln(w) + if len(fi.DigitMap) > 0 { + writeDigitMapCompact(w, fi.DigitMap) + } +} + func writeTypeMessage(w io.Writer, t factors.NumberType) { switch t { case factors.ColossallyAbundant: @@ -107,3 +123,20 @@ func writeTypeMessage(w io.Writer, t factors.NumberType) { fmt.Fprintln(w, "This radix is practical.") } } + +func typeAbbrev(t factors.NumberType) string { + switch t { + case factors.ColossallyAbundant: + return "Colossally Abundant" + case factors.Superabundant: + return "Superabundant" + case factors.OrderedExponent: + return "Ordered Exponents" + case factors.Practical: + return "Practical" + case factors.NotPractical: + return "Not Practical" + default: + panic("Should not be possible to get here.") + } +} |
