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, ifnis squarefree (no prime to the power 2 dividesn), then Otto Hölder in 1893 proved the following amazing formulawhere

pis a prime divisor ofn/mandc(p) is the number of prime divisorsqofmthat satisfyq= 1 (modp).

In a sense that can be made precise, about 60% of integers are square free [1]. 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

[1] The number of square-free integers between 1 and *x* is asymptotically equal to 6*x*/π² as *x* → ∞.