diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-11-07 07:50:23 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-11-09 19:47:16 -0500 |
| commit | 2cc0f9607872b8bd4fc6be2656a7b7a769b538b2 (patch) | |
| tree | 5e14b4ffcbf7c0d85f17b0ed468a08b4bafa11c1 /factors/type.go | |
| parent | 7d2916a50187992f72e80ed667468e8c0b125d27 (diff) | |
Reduce golang requirement to go1.18
go1.21, the previous requirement, was released a few months ago, so not
all systems have adopted it. go1.18 is old enough that most systems
should support it, but it introduces generics, which my testing code is
highly dependent on, so I can't easily go any earlier.
Diffstat (limited to 'factors/type.go')
| -rw-r--r-- | factors/type.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/factors/type.go b/factors/type.go index 919baef..3e116af 100644 --- a/factors/type.go +++ b/factors/type.go @@ -1,7 +1,5 @@ package factors -import "slices" - // The set of all colossaly abundant numbers that are small enough // to be stored in a uint64. // The first 15 are also the first 15 superior highly composites. @@ -69,9 +67,9 @@ const ( // Type determines the [CompositenessType] of a number. func Type(n uint) CompositenessType { - if slices.Contains(colossallyAbundantNums[:], uint64(n)) { + if contains(colossallyAbundantNums[:], uint64(n)) { return ColossallyAbundant - } else if slices.Contains(superabundantNums[:], uint64(n)) { + } else if contains(superabundantNums[:], uint64(n)) { return Superabundant } else if exponentsOrdered(n) { return OrderedExponent @@ -99,7 +97,7 @@ func exponentsOrdered(n uint) bool { } pf := PrimeFactorize(n) - maxPrime := slices.Max(pf.Primes()) + maxPrime := maxUints(pf.Primes()) for prime, prevPrime := uint(3), uint(2); prime <= maxPrime; { if pf.Exponent(prime) > pf.Exponent(prevPrime) { @@ -122,8 +120,7 @@ func practical(n uint) bool { } pf := PrimeFactorize(uint(n)) - primes := pf.Primes() - slices.Sort(primes) + primes := sortUints(pf.Primes()) // algorithm from Wikipedia for i := 0; i < pf.Size()-1; i++ { |
