Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,54 @@
extension BinaryInteger {
@inlinable
public func countDivisors() -> Int {
var workingN = self
var count = 1
while workingN & 1 == 0 {
workingN >>= 1
count += 1
}
var d = Self(3)
while d * d <= workingN {
var (quo, rem) = workingN.quotientAndRemainder(dividingBy: d)
if rem == 0 {
var dc = 0
while rem == 0 {
dc += count
workingN = quo
(quo, rem) = workingN.quotientAndRemainder(dividingBy: d)
}
count += dc
}
d += 2
}
return workingN != 1 ? count * 2 : count
}
}
var antiPrimes = [Int]()
var maxDivs = 0
for n in 1... {
guard antiPrimes.count < 20 else {
break
}
let divs = n.countDivisors()
if maxDivs < divs {
maxDivs = divs
antiPrimes.append(n)
}
}
print("First 20 anti-primes are \(Array(antiPrimes))")