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. --- factors/factors_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'factors/factors_test.go') diff --git a/factors/factors_test.go b/factors/factors_test.go index 8373ede..6b56e25 100644 --- a/factors/factors_test.go +++ b/factors/factors_test.go @@ -71,6 +71,15 @@ func TestTotativeRatio(t *testing.T) { tableTest(t, TotativeRatio, totativeRatioCases, stdEquals, "TotativeRatio") } +var totativeCountCases = map[uint]uint{ + 1: 1, 2: 1, 3: 2, 4: 2, 6: 2, 7: 6, 8: 4, 12: 4, + 14: 6, 15: 8, 30: 8, 60: 16, 120: 32, +} + +func TestTotativeCount(t *testing.T) { + tableTest(t, TotativeCount, totativeCountCases, stdEquals, "TotativeCount") +} + var factorScoreCases = map[uint]float64{ 1: 1.0, 2: 1.5, -- cgit v1.2.3