I thought it would be fun to give my froshling students a short programming assignment to characterize numbers as: deficient, abundant, perfect, and prime. Then I got a little carried away and started looking for weird numbers.
A number is weird if it is abundant and not semiperfect. Semiperfect means that some subset of its divisors adds up to the number.
But then I ran the code and found something very weird. The vast majority of weird numbers have exactly 15 divisors. I had some idle cores laying about, and I ran out to 25.6 million (256 cores). If I look at the count of the number of weird numbers that had a given number of divisors I get:
2 {11}
62348 {15}
6 {19}
6596 {23}
38 {27}
2 {7}
The way to read this is: "2 out of 25.6 million had 11 divisors". The vast majority have exactly 15, about 1/10 as many have 23, and then you can see what happens.
My question is: Why? I have asked some clever people, number theorists and algebraists, and they shrug.
Here is the code in Python. The actual code to run through 25.6 million was in C.
#!/usr/bin/env python3
def divisors(n):
return [ _ for _ in range(1, n) if n % _ == 0 ]
def combination(d):
for c in range(2**len(d)):
yield [ _ for _ in range(len(d)) if c & 2**_ ]
def semiperfect(d, n):
for c in combination(d):
if sum([ d[_] for _ in c ]) == n:
return True
return False
def classify(n):
d = divisors(n)
s = sum(d)
if s == 1:
return "prime"
elif s == n:
return "perfect"
elif s < n:
return "deficient"
elif not semiperfect(d, n):
return "weird"
else:
return "abundant"
def main():
for i in range(10000):
print(f"{i} {divisors(i)} is {classify(i)}")
if __name__ == '__main__':
try:
main()
except:
print("Quit")
```