TITLE: Groups where all elements are order 3
QUESTION [16 upvotes]: I am a student trying to learn some abstract algebra this summer, and I recently proved (as an exercise) that if $G$ is a group where every element has order 2, then $G$ is abelian. I was wondering could we make a similar conclusion about groups where every element has order 3, namely I am asking if $G$ is a group where all elements have order 3, then $G$ is abelian. I think that this is not true, but I cannot think of a counterexample. 
The only groups that I can think of which have all elements order 3 are the groups $(\mathbb{Z}/3\mathbb{Z})^n$, but these are abelian. Any help is appreciated. Thanks!

REPLY [30 votes]: The standard example is the Heisenberg group. Consider the group of all matrices of the form
$$\left(\begin{array}{ccc}
1 & x & y\\
0 & 1 & z\\
0 & 0 & 1
\end{array}\right),$$
where $x,y,z\in\mathbb{Z}/3\mathbb{Z}$. It is not hard to verify that this is a group, that every one of its 27 elements is of exponent $3$, and that it is not abelian.  Replacing $\mathbb{Z}/3\mathbb{Z}$ with $\mathbb{Z}/p\mathbb{Z}$ for odd prime $p$ shows that a similar result cannot hold for any prime other than $p=2$.
This is an example of smallest possible order: a finite group in which every element is of exponent  $3$ must have order $3^n$ for some $n$ (a consequence of Cauchy's Theorem), and every group of order $3^2$ is abelian.
There is another nonabelian group of order $27$, but in that group there is an element of order $9$:
$$\langle a,b\mid a^9 = b^3 = 1, ba = a^4b\rangle.$$

REPLY [3 votes]: No, it isn't true, but if you're beginning with this stuff perhaps you won't fully understand the example: the semidirect product of a non-cyclic group of order $9$ by a group of order $3$ has all its non-unit elements of order 3...
You can read here http://groupprops.subwiki.org/wiki/Prime-cube_order_group:U(3,3) an exposition about this one as a group of unitriangular matrices.