diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-09-04 15:29:22 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-09-04 18:03:36 -0500 |
| commit | 0e58327b195fa4926ba6977f48c7f535ed17d933 (patch) | |
| tree | dcc4b19f985f5acf54713c71a401091712efe7bf /factor_info.go | |
| parent | c9a0a5fd748778cb068f88c4bd29147e5b8f28e9 (diff) | |
Add totative digit count to non-compact output
This is done for a few reasons:
- Allow the user to easily determine the exact value of the totative
ratio
- This information is important when the digit map isn't accessible (for
radices >36)
- More consistency with factors
I don't show the exact values of totatives like I do with factors
because they're far more common - the superior highly composite (i.e.
one of the numbers with the highest factor count) number 720720 has
240 factors and 138240 totatives, for example.
Diffstat (limited to 'factor_info.go')
| -rw-r--r-- | factor_info.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/factor_info.go b/factor_info.go index ce014ed..93cb9d2 100644 --- a/factor_info.go +++ b/factor_info.go @@ -20,6 +20,9 @@ type FactorInfo struct { Factors []uint // An estimate of the utility of the radix's factors. Score float64 + // The number of digits that are totatives (numbers that share no + // factors with the radix - they are the worst kind of digits) + TotativeCount uint // The fraction of digits that are totatives (numbers that share no // factors with the radix - they are the worst kind of digits) TotativeRatio float64 @@ -70,15 +73,16 @@ func GetFactorInfo(radix uint) *FactorInfo { } return &FactorInfo{radix, factors.PrimeFactorize(radix), - r_factors, factors.Score(radix), factors.TotativeRatio(radix), - factors.BasicRank(radix), r_type_ptr, mtc_ptr, - math.Log(float64(radix)), digitMap} + r_factors, factors.Score(radix), factors.TotativeCount(radix), + factors.TotativeRatio(radix), factors.BasicRank(radix), + r_type_ptr, mtc_ptr, math.Log(float64(radix)), digitMap} } func (fi *FactorInfo) WriteTo(w io.Writer) { fmt.Fprintln(w, fi.Radix, "=", fi.PrimeFactorization) fmt.Fprintf(w, "Factors: %v (Score: %.4f)\n", fi.Factors, fi.Score) - fmt.Fprintf(w, "Totative Ratio: %.3f%%\n", fi.TotativeRatio * 100.0) + fmt.Fprintf(w, "Totative Digit Count: %d (%.3f%%)\n", + fi.TotativeCount, fi.TotativeRatio * 100.0) fmt.Fprintln(w, "2345 Rank:", fi.BasicRank) if fi.Type != nil { writeTypeMessage(w, *fi.Type) |
