For which $n$ is there only one group of order $n$? 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\}$?
 A: If $p$ is the smallest prime dividing $n$, then if $n=pm$ and $p|\phi(m)$ then there 
exists a semidirect product of the cyclic group of order $p$ and the cyclic group of order $m$.  So $f(n)$ is not $1$ for such $n$.  Now given a prime $p$, most values of $m$ that are 
odd and coprime to $p$ will have $\phi(m)$ being a multiple of $p$ (all we need is some prime factor of $m$ to be $1\pmod p$, and usually $m$ will have some such factors).  Since most numbers won't be coprime to all small primes, this will give a proof that the density of numbers with $f(n)=1$ is zero.  
Note:  Mark Lewko posted the interesting reference to Erdos, Murty & Murty while I was writing the answer above.  Comparing our answers, one can see that the numbers with $f(n)=1$ are closely related to the numbers $n$ having no prime factor below $\log \log n$.  
A: $f(n)=1$ if and only if $\gcd(n,\phi(n))=1$, where $\phi$ is the Euler phi-function. These $n$ are tabulated at http://oeis.org/A003277
The result is found in Tibor Szele, Über die endichen Ordnungszahlen, zu denen nur eine Gruppe gehört, Comment. Math. Helv. 20 (1947) 265–267, MR0021934 (9,131b). 
A: Let $G(x)$ denote the number of $n \leq x$ such that there is exactly $1$ isomorphism class of groups of order $n$.  Then:
$$G(x) \sim e^{-\gamma}\frac{x}{\log\log\log(x)} $$
where $\gamma$ is Euler's constant. This is a result of Erdos, Murty and Murty. Their paper also contains other interesting results on the distribution of values of the group order function.
A: 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.
