diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-10-09 16:25:09 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-10-09 16:25:09 -0500 |
| commit | 7fe152e1de2ce0ff9716d54bd03ec090a601824a (patch) | |
| tree | 0135b63f92f10c055f502ab91724ad8d08d6ed2e | |
| parent | c50ece109cdb29ab5d3fa7444040b546da7e360c (diff) | |
factors: Give Type proper name & zero value
| -rw-r--r-- | factor_info.go | 8 | ||||
| -rw-r--r-- | factors/table_test.go | 14 | ||||
| -rw-r--r-- | factors/type.go | 24 |
3 files changed, 23 insertions, 23 deletions
diff --git a/factor_info.go b/factor_info.go index becc08a..a6710e7 100644 --- a/factor_info.go +++ b/factor_info.go @@ -34,7 +34,7 @@ type factorInfo struct { // Whether or not this radix is part of any special factor-related classes. // This is not calculated if the radix is too large - in this case // this field will be nil. - Type factors.NumberType + Type factors.CompositenessType // An estimate of the complexity of the radix's multiplication table. // This is not calculated if the radix is too large - in this case // this field will be nil. @@ -146,7 +146,7 @@ func (fi *factorInfo) writeToCompact(w io.Writer) { } } -func writeTypeMessage(w io.Writer, t factors.NumberType) { +func writeTypeMessage(w io.Writer, t factors.CompositenessType) { switch t { case factors.ColossallyAbundant: fmt.Fprintln(w, "This radix is colossally abundant!") @@ -159,7 +159,7 @@ func writeTypeMessage(w io.Writer, t factors.NumberType) { } } -func typeAbbrev(t factors.NumberType) string { +func typeAbbrev(t factors.CompositenessType) string { switch t { case factors.ColossallyAbundant: return "Colossally Abundant" @@ -169,7 +169,7 @@ func typeAbbrev(t factors.NumberType) string { return "Ordered Exponents" case factors.Practical: return "Practical" - case factors.NotPractical: + case factors.None: return "Not Practical" default: panic("Should not be possible to get here.") diff --git a/factors/table_test.go b/factors/table_test.go index ab06aba..e288c3b 100644 --- a/factors/table_test.go +++ b/factors/table_test.go @@ -240,16 +240,16 @@ func TestPractical(t *testing.T) { tableTest(t, practical, practicalCases, stdEquals, "practical") } -var typeCases = map[uint]NumberType{ - 2: ColossallyAbundant, 3: NotPractical, 4: Superabundant, - 6: ColossallyAbundant, 8: OrderedExponent, 10: NotPractical, +var typeCases = map[uint]CompositenessType{ + 2: ColossallyAbundant, 3: None, 4: Superabundant, + 6: ColossallyAbundant, 8: OrderedExponent, 10: None, 12: ColossallyAbundant, 18: Practical, 20: Practical, 24: Superabundant, - 28: Practical, 30: OrderedExponent, 31: NotPractical, 34: NotPractical, - 60: ColossallyAbundant, 70: NotPractical, 90: Practical, 100: Practical, + 28: Practical, 30: OrderedExponent, 31: None, 34: None, + 60: ColossallyAbundant, 70: None, 90: Practical, 100: Practical, 120: ColossallyAbundant, 144: OrderedExponent, 180: Superabundant, 240: Superabundant, 360: ColossallyAbundant, 720: Superabundant, - 770: NotPractical, 900: OrderedExponent, 1680: Superabundant, - 1729: NotPractical, 6912: OrderedExponent, 10010: NotPractical, + 770: None, 900: OrderedExponent, 1680: Superabundant, + 1729: None, 6912: OrderedExponent, 10010: None, 10080: Superabundant, 15120: Superabundant, 25200: Superabundant, 27720: Superabundant, 55440: ColossallyAbundant, } diff --git a/factors/type.go b/factors/type.go index 91eb94e..919baef 100644 --- a/factors/type.go +++ b/factors/type.go @@ -42,33 +42,33 @@ var superabundantNums = [...]uint64{ } // A classification of numbers, based on how many factors they have. -// Each type is a subset of the next (except [Practical] and [NotPractical]), +// Each type is a subset of the next +// (except [Practical] and [NoneOfTheAbove]), // so a number is only counted as its most exclusive type. -// The zero value of this type is invalid. -type NumberType byte +type CompositenessType byte const ( // A number whose factor score is higher than any other, // if you adjust for size by dividing by some power of the number // (different powers yield different best numbers). // All colossally abundant numbers are also superabundant. - ColossallyAbundant NumberType = 0xC0 + ColossallyAbundant CompositenessType = 0xC0 // A number whose factor score is higher than any smaller number. // All superabundant numbers have ordered exponents. - Superabundant NumberType = 0xA0 + Superabundant CompositenessType = 0xA0 // A number whose prime factorization exponents stay the same or decrease // as you go from smaller to larger primes. // All of these numbers are also practical. - OrderedExponent NumberType = 0x80 + OrderedExponent CompositenessType = 0x80 // A number whose factors can sum to any smaller number without duplication. // All practical numbers besides 1 and 2 are divisible by 4 or 6. - Practical NumberType = 0x60 - // None of the above types - NotPractical NumberType = 0x40 + Practical CompositenessType = 0x60 + // None of the above types. This is the zero value of CompositenessType. + None CompositenessType = 0x00 ) -// Type determines the [NumberType] of a number. -func Type(n uint) NumberType { +// Type determines the [CompositenessType] of a number. +func Type(n uint) CompositenessType { if slices.Contains(colossallyAbundantNums[:], uint64(n)) { return ColossallyAbundant } else if slices.Contains(superabundantNums[:], uint64(n)) { @@ -78,7 +78,7 @@ func Type(n uint) NumberType { } else if practical(n) { return Practical } else { - return NotPractical + return None } } |
