From 0e58327b195fa4926ba6977f48c7f535ed17d933 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Mon, 4 Sep 2023 15:29:22 -0500 Subject: 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. --- factor_info.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'factor_info.go') 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) -- cgit v1.2.3