Understanding the Hidden Subgroup Problem specific to Integer Factorization
Let $\mathbb{Z}, +$ be the group integers, $\mathbb{Z}/n\mathbb{Z}, \times$ the multiplicative group of integers modulo $n$, and $\varphi(n)$ its order. Then $\varphi(n)\mathbb{Z}, +$, the additive group of multiples of $\varphi(n)$ is a subgroup of $\mathbb{Z}$. The function $f : \mathbb{Z} \rightarrow \mathbb{Z}/n\mathbb{Z} : x \mapsto a^x \mod n$ for fixed $a \in \mathbb{Z}/n\mathbb{Z}$ satisfies the description of the HSP oracle for the subgroup $H=\varphi(n)\mathbb{Z}$ of $\mathbb{Z}$ because

$\phantom{\Leftrightarrow} \forall \, x, y \in \mathbb{Z} \, . \, f(x) = f(y) \\
\Leftrightarrow x = y \mod \varphi(n) \\
\Leftrightarrow x = y + k\varphi(n) \quad \mathit{for \, some} \quad k \in \mathbb{Z} \\
\Leftrightarrow x = y + H$

Consequently, the formulation of the factorization problem is to find a generator of the group $\varphi(n)\mathbb{Z} \subset \mathbb{Z}$ given access to the function $f$ that computes exponentiation modulo $n$. Once you have this generator, $\varphi(n)$, computing the factorization of $n$ is easy using some straightforward (classical) number theory.