$|G| = 4$:
Each element (besides the identity) must have order
2 or 4. If $a \in G$ has order 4 it generates $G$ and
we have $G = \mathbb{Z}_4$. Otherwise every element has
order 2 and by the lemma we have $G = \mathbb{Z}_2 \times \mathbb{Z}_2$
(the four-group or quadratic group,
sometimes denoted by $V$ after F. Klein’s "Vierergruppe").

$|G| = 6$:
If $a \in G$ has order 6 we have $G = \mathbb{Z}_6$.
Otherwise all elements (besides the identity) have order 2 or 3. By the
lemma, not all elements can have order 2 because 6 is not a power of 2.
So let $a$ be an element of order 3, that is $1,a,a^2$ are distinct. Let
$b$ be some other element in $G$. It can be verified that
$1,a,a^2,b,a b,a^2 b$ must be distinct. In order to satisfy closure, $b^2$
must be one of these elements. The only possibilities are $b^2 = 1,a$ or
$a^2$.

If $b^2=a,a^2$ we find that $b$ cannot have order 2, so it has order 3.
Then $1 = a b$ or $1 =a^2 b$, both of which are contradictions. Hence
$b^2 = 1$. Next we determine which element is equal to $b a$. The only
possible choices are $a b$ or $a^2 b$. If $b a = a b$, then $G$ is
abelian, but then $(a b)^2 = a^2$ and $(a b)^3 = b$ implying that $a b$
has order 6, a contradiction. Thus $b a = a^2 b$, implying $(a b)^2 = 1$.
We have defining relations $a^3 = b^2 = (a b)^2 = 1$. We shall see
later that this is indeed a group (associativity turns out to hold) because
it is the symmetric group of degree 3 (which
is isomorphic to the dihedral group of
order 6).

$|G|=8$: It turns out there are 3 abelian groups and 2 nonabelian groups.
The three abelian groups are easy to classify:
$\mathbb{Z}_8, \mathbb{Z}_4 \times \mathbb{Z}_2, \mathbb{Z}_2 \times \mathbb{Z}_2 \times \mathbb{Z}_2$.

The other groups must have the maximum order of any element greater than 2
but less than 8. Hence there exists an element of order 4, which we denote
by $a$. All the others (besides the identity) have order 2 or 4. Let
$b$ be an element not generated by $a$. Then we have the distinct elements
$1,a,a^2,a^3,b,a b,a^2 b,a^3 b$. Now $b^2$ can only be one of the first
four. But $b^2 = a, a^3$ imply $b$ is not of order 2 or 4, so we must have
$b^2 =1$ or $b^2= a^2$.

Suppose $b^2 = 1$. Now $b a$ must be equal to one of the last three elements.
If $b a = a b$ then the group is abelian and we end up with the
aforementioned $\mathbb{Z}_4 \times \mathbb{Z}_2$.
If $b a = a^2 b$, then we have $b^{-1}a^2 b = a$. Upon squaring, we derive
the contradictory $a^2 = 1$. So we must have $b a = a^3 b$, that is,
$(a b)^2 = 1$. The defining relations are $a^4 = b^2 = (a b)^2 = 1$, and
this turns out to be the
dihedral group of order 8, also known as
the octic group.

The other possibility is $b^2 = a^2$. In this case, $b$ also has order 4.
If $b a = a b$ then the group is abelian and again we wind up with the
group $\mathbb{Z}_4 \times \mathbb{Z}_2$. If $b a = a^2 b$ we have
$b a = b^3$, which is a contradiction because it implies $a = b^2 = a^2$.
Thus we must have $b a = a^3 b$. Then we get a group with the defining
relations $a^4 = 1, a^2 = b^2, ba = a^3 b$, which is known as the
quaternion group. To verify associativity, one can
show it is isomorphic to the group generated by the matrices

The quaternion group is a special case of a dicyclic group,
groups of order $4 m$ given by $a^{2m} = 1, a^m = (a b)^2 = b^2$, and
whose elements can be written $1,a,...,a^{2m-1},b,a b,...,a^{2m -1}b$. The
square of elements not generated by $a$ is $b^2$.