On orders of a quadratic number field
Let $K$ be an algebraic number field of degree $n$. An order of $K$ is a subring $R$ of $K$ such that $R$ is a free $\mathbb{Z}$-module of rank $n$. Let $\alpha_1, \cdots, \alpha_n$ be a basis of $R$ as a $\mathbb{Z}$-module. Let $d = \det(\operatorname{Tr}_{K/\mathbb{Q}}(\alpha_i\alpha_j))$. It is easy to see that $d$ is independent of a choice of a basis of $R$. We call $d$ the discriminant of $R$.
Is the following proposition true? If yes, how can we prove it?
Proposition Let $K$ be a quadratic number field. Let $\mathcal{O}_K$ be the ring of algebraic integers in $K$. Let $f \gt 0$ be a positive integer. Then there exists a unique order $R$ of $K$ such that $f$ is the order of the group $\mathcal{O}_K/R$. Moreover, the discriminant of $R$ is $f^2 d$, where $d$ is the discriminant of $K$.
Definition Let $K$ be a quadratic number field. Let $\mathcal{O}_K$ be the ring of algebraic integers in $K$. By Lemma 4 in my answer to this question, there exists a unique square-free integer $m$ such that $K = \mathbb{Q}(\sqrt m)$.
If $m \equiv 1$ (mod $4$), let $\omega = (1 + \sqrt m)/2$.
If $m \equiv 2, 3$ (mod $4$), let $\omega = \sqrt m$.
By Lemma 6 in my answer to this question, $1, \omega$ is a basis of $\mathcal{O}_K$ as a $\mathbb{Z}$-module. We call $1, \omega$ the canonical integral basis of $K$.
Lemma 1 Let $K$ be a quadratic number field. Let $1, \omega$ be the canonical integral basis of $K$. Let $f \gt 0$ be a positive integer. Then $R = \mathbb{Z} + \mathbb{Z}f\omega$ is an order of $K$.
Proof: Let $\mathcal{O}_K$ be the ring of integers in $K$. It suffices to prove that $R$ is a subring of $\mathcal{O}_K$.
$(f\omega)^2 = f^2 \omega^2 \in f^2\mathcal{O}_K \subset R$.
Hence $f\omega R \subset R$. Hence $R^2 \subset R$. Hence $R$ is a subring of $\mathcal{O}_K$.
Lemma 2 Let $K$ be a quadratic number field. Let $1, \omega$ be the canonical integral basis of $K$. Let $R$ be an order of $K$. Then there exists an integer $f \gt 0$ such that $1, f\omega$ is a basis of $R$ as a $\mathbb{Z}$-module.
Proof: Let $\mathcal{O}_K$ be the ring of integers in $K$. Let $n$ be the order of the abelian group $\mathcal{O}_K/R$. Then $n$ is finite and $n\mathcal{O}_K \subset R$. Hence $n\omega \in R$. Let $f$ be the least positive integer such that $f\omega \in R$. Let $\alpha$ be an element of $R$. Since $R \subset \mathcal{O}_K$, there exist rational integers $a, b$ such that $\alpha = a + b\omega$. Let $b = fq + r$, where $q$ and $r$ are rational integers and $0 \le r \lt f$. Then $\alpha - qf\omega = a + r\omega$. Hence $r\omega \in R$. Hence $r = 0$ by the assmption on $f$. Hence $\alpha \in \mathbb{Z} + \mathbb{Z}f\omega$. Hence $R \subset \mathbb{Z} + \mathbb{Z}f\omega$. The other inclusion is clear.
Proposition Let $K$ be a quadratic number field. Let $\mathcal{O}_K$ be the ring of algebraic integers in $K$. Let $f \gt 0$ be a positive integer. Then there exists a unique order $R$ of $K$ such that $f$ is the order of the group $\mathcal{O}_K/R$. Moreover, the discriminant of $R$ is $f^2 d$, where $d$ is the discriminant of $K$.
Proof: Let $1, \omega$ be the canonical integral basis of $K$. By Lemma 1, $R = \mathbb{Z} + \mathbb{Z}f\omega$ is an order of $K$. Clearly $f$ is the order of the group $\mathcal{O}_K/R$.
Next we will prove the uniqueness of $R$. Let $S$ be an order of $K$ such that $f$ is the order of the group $\mathcal{O}_K/S$. By Lemma 2, there exists an integer $g \gt 0$ such that $1, g\omega$ is a basis of $S$ as a $\mathbb{Z}$-module. Since $g$ is the order of the group $\mathcal{O}_K/S$, $f = g$. Hence $R = S$.
Let $\omega'$ be the conjugate of $\omega$. Then the discriminant of $R$ is $(f\omega - f\omega')^2 = f^2(\omega - \omega')^2 = f^2 d$.