[guided]When $p \mid (q - 1)$, the Sylow analysis from the first step still gives $n_q = 1$, so $Q \trianglelefteq G$. However, $n_p$ is no longer forced to be $1$: we have $n_p \in \{1, q\}$ and $n_p = q$ is now consistent with the congruence $n_p \equiv 1 \pmod{p}$, since $p \mid (q - 1)$ means $q \equiv 1 \pmod{p}$. So we cannot conclude $P \trianglelefteq G$ from Sylow alone.
**Expressing $G$ as a semidirect product.** Regardless of whether $P$ is normal, we can still describe $G$ structurally. Fix a Sylow $p$-subgroup $P \le G$. Since $Q \trianglelefteq G$ and $P \cap Q = \{e\}$ (because $|P \cap Q|$ divides $\gcd(p, q) = 1$ by [Lagrange's Theorem](/theorems/782)), and $|PQ| = |P| \cdot |Q| / |P \cap Q| = pq = |G|$, the group satisfies $G = PQ$ with $Q \trianglelefteq G$ and $P \cap Q = \{e\}$. This is precisely the condition for $G$ to be the internal semidirect product $G = Q \rtimes_\varphi P$, where $\varphi: P \to \operatorname{Aut}(Q)$ is the conjugation action: $\varphi(a)(b) = aba^{-1}$ for $a \in P$, $b \in Q$. (The action is well-defined because $Q \trianglelefteq G$ guarantees $aba^{-1} \in Q$.)
**Classifying the homomorphisms $\varphi: \mathbb{Z}/p\mathbb{Z} \to \operatorname{Aut}(\mathbb{Z}/q\mathbb{Z})$.** Since $|P| = p$ and $|Q| = q$ are prime, both are cyclic: $P \cong \mathbb{Z}/p\mathbb{Z}$ and $Q \cong \mathbb{Z}/q\mathbb{Z}$. The automorphism group $\operatorname{Aut}(\mathbb{Z}/q\mathbb{Z}) \cong (\mathbb{Z}/q\mathbb{Z})^\times$ is cyclic of order $q - 1$ (each automorphism is multiplication by a unit mod $q$). A group homomorphism from $\mathbb{Z}/p\mathbb{Z}$ into any group is entirely determined by the image of a generator $t \in \mathbb{Z}/p\mathbb{Z}$, and that image must have order dividing $p$. So we need elements of order dividing $p$ in $(\mathbb{Z}/q\mathbb{Z})^\times$.
There are two types of such elements: the identity (order $1$), and elements of order exactly $p$. Sending $t$ to the identity gives the constant homomorphism $\varphi \equiv \operatorname{id}$; this yields the direct product $G \cong \mathbb{Z}/q\mathbb{Z} \times \mathbb{Z}/p\mathbb{Z} \cong \mathbb{Z}/pq\mathbb{Z}$. Since $p \mid (q - 1)$ and $(\mathbb{Z}/q\mathbb{Z})^\times$ is cyclic of order $q - 1$, there exists a unique subgroup of order $p$ in $(\mathbb{Z}/q\mathbb{Z})^\times$ (a cyclic group has exactly one subgroup of each order dividing its order). This subgroup has $p - 1$ generators, each of order $p$, giving exactly $p - 1$ non-constant homomorphisms $\varphi: \mathbb{Z}/p\mathbb{Z} \to (\mathbb{Z}/q\mathbb{Z})^\times$.
**Do different non-constant homomorphisms yield non-isomorphic groups?** No — all non-constant homomorphisms produce isomorphic semidirect products. Here is the explicit verification. Let $t$ be a generator of $\mathbb{Z}/p\mathbb{Z}$. Let $\varphi, \varphi': \mathbb{Z}/p\mathbb{Z} \to \operatorname{Aut}(\mathbb{Z}/q\mathbb{Z})$ be two non-constant homomorphisms. Write $\varphi(t) = \alpha$ where $\alpha \in \operatorname{Aut}(\mathbb{Z}/q\mathbb{Z})$ has order $p$. Since $\varphi'$ is also non-constant, $\varphi'(t)$ lies in the unique subgroup of order $p$ in $\operatorname{Aut}(\mathbb{Z}/q\mathbb{Z})$, which is generated by $\alpha$. Thus $\varphi'(t) = \alpha^k$ for some $1 \le k \le p - 1$.
Since $\gcd(k, p) = 1$ (if $p \mid k$ then $\alpha^k = \operatorname{id}$, contradicting $\varphi'$ being non-constant), $k$ is invertible modulo $p$. Define $\psi: \mathbb{Z}/p\mathbb{Z} \to \mathbb{Z}/p\mathbb{Z}$ by $\psi(s) = s^k$ (i.e., multiplication by $k$ in $\mathbb{Z}/p\mathbb{Z}$). Since $\gcd(k, p) = 1$, $\psi$ is an automorphism of $\mathbb{Z}/p\mathbb{Z}$. Moreover, $\varphi'(t) = \alpha^k = \varphi(t^k) = \varphi(\psi(t))$, so $\varphi' = \varphi \circ \psi$. Now define
\begin{align*}
\Theta: \mathbb{Z}/q\mathbb{Z} \rtimes_{\varphi'} \mathbb{Z}/p\mathbb{Z} &\to \mathbb{Z}/q\mathbb{Z} \rtimes_\varphi \mathbb{Z}/p\mathbb{Z} \\
(a, s) &\mapsto (a,\, \psi(s)) = (a,\, s^k).
\end{align*}
We verify $\Theta$ is a group homomorphism. The multiplication rule in $\mathbb{Z}/q\mathbb{Z} \rtimes_{\varphi'} \mathbb{Z}/p\mathbb{Z}$ is $(a, s)(b, s') = (a + \varphi'(s)(b),\, s + s')$. Applying $\Theta$:
\begin{align*}
\Theta\bigl((a, s)(b, s')\bigr) = \Theta\bigl(a + \varphi'(s)(b),\, s + s'\bigr) = \bigl(a + \varphi'(s)(b),\, (s + s')^k\bigr).
\end{align*}
Since $\psi$ is a group homomorphism (i.e., $(s + s')^k = s^k + {s'}^k$ in $\mathbb{Z}/p\mathbb{Z}$) and $\varphi'(s) = \varphi(\psi(s)) = \varphi(s^k)$, this equals $(a + \varphi(s^k)(b),\, s^k + {s'}^k)$. On the other hand:
\begin{align*}
\Theta(a, s) \cdot \Theta(b, s') = (a, s^k)(b, {s'}^k) = (a + \varphi(s^k)(b),\, s^k + {s'}^k).
\end{align*}
These are equal, so $\Theta$ is a homomorphism. Since $\psi$ is an automorphism, the map $(a, s) \mapsto (a, s^k)$ is both injective and surjective, so $\Theta$ is an isomorphism. Therefore $\mathbb{Z}/q\mathbb{Z} \rtimes_{\varphi'} \mathbb{Z}/p\mathbb{Z} \cong \mathbb{Z}/q\mathbb{Z} \rtimes_\varphi \mathbb{Z}/p\mathbb{Z}$.
**Conclusion.** There are exactly two isomorphism classes of groups of order $pq$ when $p \mid (q - 1)$:
- The cyclic group $\mathbb{Z}/pq\mathbb{Z}$, arising when $\varphi$ is the constant homomorphism (sending every element to $\operatorname{id}$), in which case $G$ is abelian and $n_p = 1$.
- The unique non-abelian group $\mathbb{Z}/q\mathbb{Z} \rtimes_\varphi \mathbb{Z}/p\mathbb{Z}$, arising when $\varphi$ is any non-constant homomorphism; all such choices yield isomorphic groups, and $n_p = q$ in this case.
These two classes are distinct because the non-abelian group is not abelian while $\mathbb{Z}/pq\mathbb{Z}$ is abelian (in particular, the non-abelian group is not cyclic).[/guided]