From 2cc0f9607872b8bd4fc6be2656a7b7a769b538b2 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 7 Nov 2023 07:50:23 -0500 Subject: 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. --- factors/type.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'factors/type.go') 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++ { -- cgit v1.2.3