TITLE: For which $n$ is there only one group of order $n$?
QUESTION [35 upvotes]: Let $f(n)$ denote the number of (isomorphism classes of) groups of order $n$. A couple easy facts:

If $n$ is not squarefree, then there are multiple abelian groups of order $n$.
If $n \geq 4$ is even, then the dihedral group of order $n$ is non-cyclic.

Thus, if $f(n) = 1$, then $n$ is a squarefree odd number (assuming $n \geq 3$). But the converse is false, since $f(21) = 2$.
Is there a good characterization of $n$ such that $f(n) = 1$? Also, what's the asymptotic density of $\{n: f(n) = 1\}$?

REPLY [17 votes]: The original question has already been answered, so I thought I would provide a slightly more general version.
The short paper http://www.math.ku.dk/~olsson/manus/three-group-numbers.pdf describes those  orders for which there are precisely 1, 2 or 3 groups of the given order.