On the class group of an imaginary quadratic number field Let $d < 0$ be a square-free integer and let $p_{1},\ldots p_{r}$ be the prime divisors of $d$. Let $K := \mathbb{Q}[\sqrt{d}]$ and consider $P_{i} := (p_{i}, \sqrt{d}) \subset \mathcal{O}_{K}$. Then, the classes of $P_{1}, \ldots P_{r}$ generate a subgroup of $Cl(K)$ isomorphic to $\left(\mathbb{Z}/2\mathbb{Z}\right)^{r−1}$.
(standard notations: $Cl(K)$ denotes the class group of $K$, whereas $O_{K}$ is the ring of integers)
I'm having trouble with this result which I heard belongs to Gauss. I can't find a proof. Can anyone help or provide a reference? Thanks!
This is really interesting since we get the order of $2$ in the class number in terms of the number of prime divisors of the squarefree $d$.
 A: It is better not to consider the square-free integer $d$ directly, but rather $D_K$, the discriminant of $K$, which equals $d$ if $d \equiv 1 \bmod 4$, but equals $4d$ otherwise.
A rational prime $p$ is ramified in $K$ if and only if $p | D_K$, and then the correct statement is that, if $\mathfrak p_i$ are the primes of $K$ lying over the ramified primes $p_i$, then the prime ideals $\mathfrak p_i$ generate the $2$-torsion subgroup of $Cl(K)$ (and here I really mean $2$-torsion, not $2$-power-torsion), and the rank of this subgroup is $r-1$ (if $r$ is the number of such primes, i.e. the number of primes dividing $D_K$).  (They satisfy the relation that their product 
is equal to $\sqrt{D_K}\mathcal O_K$, which is principal, which is why the rank is $r-1$ rather than $r$.)
This statement is (part of what is) known as genus theory, and (as you note) is due to Gauss (although reinterpreted in our more modern language).
One text that discusses this theory is Harvey Cohn's Advanced number theory.
Note that there is an analogous theory for real quadratic fields, but it is slightly more subtle, because of the possible difference between the class group and the strict class group, and the presence of non-trivial units.
[Added: In response to the question in a comment above, to show that any
proper product of the $\mathfrak p_i$s is not principal, use an argument with
norms.  This shows that the rank of the subgroup generated by the $\mathfrak p_i$
is $r-1$, and no smaller.  To see that this all the $2$-torsion is a bit harder.]
A: If $\sigma$ is the nontrivial element of Gal$(K/Q)$, one can show that $\sigma(P_i)P_i$ is generated by $p_i$. More generally, $\sigma(\prod P_i)\prod P_i$ is generated by $\prod p_i$ for any subset of indices. 
Now suppose $\prod P_i=(a+b\sqrt{d})$. We have $(\sigma(a+b\sqrt{d}))(a+b\sqrt{d})=(a^2-b^2d)=(a^2+|d|b^2)$. This generates the same ideal as $\prod p_i$ iff $a^2+|d|b^2 = \prod p_i$, since both are non-negative rational integers. This equation can be solved only if the product is empty, so that $a=\pm1, b=0$, or it includes all of the primes, so that $a=0,b=\pm1$.
