This post is a sort of footnote to the previous post, Estimating the number of groups of a given order.
The following is taken from an answer to a question on Stack Exchange.
In general there is no formula f(n) for the number of groups of order up to isomorphism. However, if n is squarefree (no prime to the power 2 divides n), then Otto Hölder in 1893 proved the following amazing formula
where p is a prime divisor of n/m and c(p) is the number of prime divisors q of m that satisfy q = 1 (mod p).
In a sense that can be made precise, about 60% of integers are square free . So Hölder’s formula is often useful, but there are a lot of values it can’t compute.
In this post I develop Python code to implement Hölder’s formula. I’ve tested the code below by comparing it to a table of f(n) for n = 1, 2, 3, …, 100.
from sympy import mobius, divisors, factorint def squarefree(n): return n > 1 and mobius(n) != 0 def prime_divisors(n): return list(factorint(n).keys()) def c(p, m): return len( [q for q in prime_divisors(m) if q % p == 1] ) def holder(n): if not squarefree(n): print("Sorry. I can't help you.") return None s = 0 for m in divisors(n): prod = 1 for p in prime_divisors(n // m): prod *= (p**c(p, m) - 1) // (p - 1) s += prod return s
 The number of square-free integers between 1 and x is asymptotically equal to 6x/π² as x → ∞.